Sorry if this is a FAQ. I am not familiar with Cython.
Now than 0.27 supports variable annotations, I try to write ".py" files
instead of ".pyx" files. The idea is to be able to run the code in the
interpreter for development and debugging, but being fast in production.
I have this example code:
"""
import cython
def a(x:
cython.int, y:
cython.int) ->
cython.int:
i:
cython.int
x2:
cython.int = 0
for i in range(y):
x2 += x
return x2
if cython.compiled:
print("COMPILED")
else:
print("Interpreted")
#import time
#t = time.time()
#a(567,17913453)
#print(time.time()-t)
"""
If this code is called "z.pyx", it works fine and fast. If it is called
"z.py", it compiles but imports fails with:
"""
ImportError: Building module z failed: ["NameError: name 'cython' is not
defined\n"]
"""
Reading the documentation, it seems than "pure python" + annotations
modules would be supported.
I have tried both the "setup.py" and "pyximport.install(inplace=True,
build_in_temp=False,pyimport=True)" options.
I am doing it wrong?. Is this a bug?.
Excuse me if this is a FAQ and I am wasting your time.
Thanks for your time and hard work!.
--
Jesús Cea Avión _/_/ _/_/_/ _/_/_/
jc...@jcea.es -
http://www.jcea.es/ _/_/ _/_/ _/_/ _/_/ _/_/
Twitter: @jcea _/_/ _/_/ _/_/_/_/_/
jabber /
xmpp:jc...@jabber.org _/_/ _/_/ _/_/ _/_/ _/_/
"Things are not so easy" _/_/ _/_/ _/_/ _/_/ _/_/ _/_/
"My name is Dump, Core Dump" _/_/_/ _/_/_/ _/_/ _/_/
"El amor es poner tu felicidad en la felicidad de otro" - Leibniz