embedded Python - optimization for creating/destroying many small objects

Paul Miller paul at fxtech.com
Mon Jun 24 12:55:04 EDT 2002

I have Python embedded and have some code that create thousands of small
Python extension objects. But my usage for these is basically to pass
some data to a Python callback. Essentially, I have a loop, and I create
my Python object (with data from a C object), call the Python function
(the callback), then decref/destroy the object.

I would like to simply create ONE of these objects and reuse it for the
entire loop, so I am not paying for the memory allocation/deallocation

Is there a prescribed way of doing stuff like this for extension

More information about the Python-list mailing list