[Cython] Storing many, many instances
Stéfan van der Walt
stefan at sun.ac.za
Mon May 4 23:43:00 CEST 2009
Hi all,
I have code that generates about 40000 instances of a certain cdef'd class.
I would like to know:
1) If I define my cdef class in my_class.pyx, and then, in main.pyx do:
from my_class import MyClass
[.. instantiate many, many MyClass objects ..]
Does this happen in C, or am I making Python calls along the way?
2) Is there a standard pattern for lowering the cost of instance creation?
I think I may have to switch to structs instead of classes, but then I
no longer have convenient methods or array members. Maybe I should
rewrite my class to have many static methods that operate on a struct,
and then collect the structs as data instead of the full instances.
Any input much appreciated,
Regards
Stéfan
More information about the Cython-dev
mailing list