Re: Caching objects in a C extension

2010-01-08 Thread casevh
On Jan 8, 8:56 am, Antoine Pitrou wrote: > Le Fri, 08 Jan 2010 08:39:17 -0800, casevh a écrit : > > > > > Thanks for the reply. I realized that I missed one detail. The objects > > are created by the extension but are deleted by Python. I don't know > > that an object is no longer needed until its

Re: Caching objects in a C extension

2010-01-08 Thread Terry Reedy
On 1/8/2010 12:50 PM, casevh wrote: These are numeric objects created by gmpy. I'm trying to minimize the overhead for using mpz with small numbers. Objects are created and deleted very often by the interpreter as expressions are evaluated. I don't keep ownership of the objects. CPython create

Re: Caching objects in a C extension

2010-01-08 Thread casevh
On Jan 8, 9:19 am, "Diez B. Roggisch" wrote: > casevh schrieb: > > > > > > > On Jan 8, 2:59 am, "Diez B. Roggisch" wrote: > >> casevh schrieb: > > >>> I'm working with a C extension that needs to rapidly create and delete > >>> objects. I came up with an approach to cache objects that are being >

Re: Caching objects in a C extension

2010-01-08 Thread Diez B. Roggisch
casevh schrieb: On Jan 8, 2:59 am, "Diez B. Roggisch" wrote: casevh schrieb: I'm working with a C extension that needs to rapidly create and delete objects. I came up with an approach to cache objects that are being deleted and resurrect them instead of creating new objects. It appears to

Re: Caching objects in a C extension

2010-01-08 Thread Antoine Pitrou
Le Fri, 08 Jan 2010 08:39:17 -0800, casevh a écrit : > > Thanks for the reply. I realized that I missed one detail. The objects > are created by the extension but are deleted by Python. I don't know > that an object is no longer needed until its tp_dealloc is called. At > that point, its reference

Re: Caching objects in a C extension

2010-01-08 Thread casevh
On Jan 8, 2:59 am, "Diez B. Roggisch" wrote: > casevh schrieb: > > > > > > > I'm working with a C extension that needs to rapidly create and delete > > objects. I came up with an approach to cache objects that are being > > deleted and resurrect them instead of creating new objects. It appears > >

Re: Caching objects in a C extension

2010-01-08 Thread Diez B. Roggisch
casevh schrieb: I'm working with a C extension that needs to rapidly create and delete objects. I came up with an approach to cache objects that are being deleted and resurrect them instead of creating new objects. It appears to work well but I'm afraid I may be missing something (besides heeding

Caching objects in a C extension

2010-01-08 Thread casevh
I'm working with a C extension that needs to rapidly create and delete objects. I came up with an approach to cache objects that are being deleted and resurrect them instead of creating new objects. It appears to work well but I'm afraid I may be missing something (besides heeding the warning in th