[Cython] Storing many, many instances

Stefan Behnel stefan_ml at behnel.de
Wed May 6 14:34:52 CEST 2009


Dag Sverre Seljebotn wrote:
> Stefan Behnel wrote:
>> Robert Bradshaw wrote:
>>> We should
>>> look into making instantiating (cdef) classes faster by default as
>>> well.
>>
>> Different topic, but surely worth it (and worth a ticket). It might work
>> to always use PY_NEW() for instantiation and then generate a separate
>> (and direct) call to __init__() only if the type defines it.
>
> Should one consider allocating arrays of cdef class objects as one big
> memory block?

We do not control the allocation, CPython handles that.


> I would think that allocating first and then run a
> constructor N times would be faster than N allocations.

How would you instantiate arrays of classes in a single step?

Stefan



More information about the Cython-dev mailing list