Trouble using eval() with cython
Posted
by Peter Stewart
on Stack Overflow
See other posts from Stack Overflow
or by Peter Stewart
Published on 2010-04-06T23:51:10Z
Indexed on
2010/04/06
23:53 UTC
Read the original article
Hit count: 439
I was trying to speed up some code, and then I tried compiling a class and a function using cython
and WOW! I havn't measured it yet but it looks at least 10x faster.
I first looked at cython just two days ago, I'm very impressed!
However, I can't get eval() to work.
def thefirst(int a):
d = eval('1+2+a')
return d
I compile this to module1.pyd file and call it with the python file:
from module1 import thefirst
x = thefirst(2)
print x
This returns:
NameError: name 'a' is not defined.
All help is appreciated.
© Stack Overflow or respective owner