On Tuesday, September 9, 2014 4:44:33 PM UTC+1, Nils Bruin wrote:
>
> In python, looking up a global flag is going to be relatively slow, 
> because, if addressed by its proper name, it involves checking several 
> __dict__s
>

Which is why it needs to be a cdef bool as I wrote earlier.

 sage: sage: cython("""
....: cdef bint sage_citation_enabled = False
....: cpdef cite():
....:     if sage_citation_enabled:
....:         raise NotImplementedError()
....: """)
sage: def t2(a):
....:         return 2*a
....: 
sage: def t4(a):
....:     cite()
....:     return 2*a
....: 
sage: timeit('t2(20)', number=100000)
100000 loops, best of 3: 360 ns per loop
sage: timeit('t4(20)', number=100000)
100000 loops, best of 3: 377 ns per loop

Not really noticable any more, especially considering that multiplying-by-2 
is a) something that really should be implented in Cython to avoid Python 
overhead and b) not something that you would cite anyways.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to