Hi,

Aaron DeVore wrote:
> Would this work if put at the top of every file (dashes indicate indentation)?
> if not hasattr(__builtin__, "set"):
> ----from sets import Set as set
> 
> or this
> try:
> ----set
> except NameError:
> ----from sets import Set as set

Just give it a try. :)

None of this can work, as Cython determines at translation time what name
refers to a built-in and what was (re-)defined somewhere. Only built-ins can
be optimised to use straight API calls in the generated C code, everything
else has to go through Python code. In all of the above cases, the name "set"
has been redefined at the global module scope (regardless of any try-except-
or if-blocks), so it is no longer associated with the built-in set type.

Stefan

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to