[Pyrex] Low level operations

Greg Ewing greg at cosc.canterbury.ac.nz
Sun Jun 29 09:19:22 CEST 2003


> It makes large use of double, unsigned short, unsigned byte arrays which
> are all dynamically allocated.
>
> How should I allocate/deallocate memory for these arrays? It seems that
> Python may not be using the 'standard' malloc/free under some
> circumstances. Does Python export its low level allocation stuff?

You can allocate memory however you want, as long as you free
it the corresponding way. For example, you can define an
extension type that allocates memory using malloc() in its
__new__ method and frees it using free() in its __dealloc__
method.

You might also like to investigate using the Numeric module.
It's possible to write Pyrex code that operates on the contents
of a Numeric array, and Numeric can take care of the reading
and writing if you want it to.

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg at cosc.canterbury.ac.nz	   +--------------------------------------+




More information about the Pyrex mailing list