[Pyrex] Pyrex idioms and optimizations?
Lenard Lindstrom
len-l at telus.net
Thu Jul 26 05:51:47 CEST 2007
William Stein wrote:
> Something that is valid in Pyrex but we think should not
> be valid is the following:
>
> # This is a complete file:
> ################
>
> def foo(a,b):
> print a + b + c
>
> ################
>
> In Pyrex it compiles fine. In SageX it gives an error
> message that c is not defined. This avoids countless
> runtime errors.
>
>
This is valid Python, though not pretty. c is a global variable. Just
assign a value to c before calling foo. But Pyrex has a bug:
>>> import foo
>>> foo.c = 12
>>> foo.foo(1, 2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "foo.pyx", line 2, in foo.foo
print a + b + c
NameError: c
--
Lenard Lindstrom
<len-l at telus.net>
More information about the Pyrex
mailing list