> It turns out that the tricky part is overriding the allocation and
> deallocation of the python objects associated with my extension class,
> as well as the extension class structure itself.

I don't really understand what you are trying to do, but it seems a bit
confused. Why don't you just cache the expensive objects in a dict global
to the module? Instead of trapping garbage collection, you can simply
avoid that it happens by keeping a reference somewhere (e.g. in a dict).

Also don't try to outsmart Python by implementing your own hashing table.
Dicts and sets have supernatural performance compared to anything you can
make on your own in reasonable time.

If you want more precise control over reference counts etc., there are
weakrefs, weakvalue dicts and weakref dicts. I used these to manage a pool
of share memory segments. It might be similar to what you are trying to
do.

http://folk.uio.no/sturlamo/python/sharedmem-feb13-2009.zip


S.M.

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to