2012/1/19 Vitja Makarov :
> 2012/1/19 Robert Bradshaw :
>> I think the right thing to do here is make all module-level globals
>> into "cdef public" attributes, i.e. C globals with getters and setters
>> for Python space. I'm not sure whether this would best be done by
>> creating a custom dict or
2012/1/19 Robert Bradshaw :
> I think the right thing to do here is make all module-level globals
> into "cdef public" attributes, i.e. C globals with getters and setters
> for Python space. I'm not sure whether this would best be done by
> creating a custom dict or module subclass, but it would pr
AFAIK, a module's dict is readonly, so I don't believe a dict subclass will
work there (I could be wrong) unless you hack up the module object from C.
You can do it with descriptors on a ModuleType however, which should be
plenty fast from Cython-land.
In [16]: class AGetter(object):
:
I think the right thing to do here is make all module-level globals
into "cdef public" attributes, i.e. C globals with getters and setters
for Python space. I'm not sure whether this would best be done by
creating a custom dict or module subclass, but it would probably be
cleaner and afford much mo
I tried to optimize module lookups (__pyx_m) by caching internal PyDict state.
In this example bar() is 1.6 time faster (500us against 842us):
C = 123
def foo(a):
return C * adef bar():
for i in range(1): foo(i)
Here is proof of
concept:https://github.com/vitek/cython/commit/1d