[Python-Dev] A little GC confusion (original) (raw)
Michael Hudson mwh@python.net
21 Feb 2002 13:47:56 +0000
- Previous message: [Python-Dev] A little GC confusion
- Next message: [Python-Dev] A little GC confusion
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Kevin Jacobs <jacobs@penguin.theopalgroup.com> writes:
I doesn't have any time to really look at your code, but I thought I'd point out a trick that several extension modules use to protect statically allocated type objects. Here is the code from socketmodule.c:
/* static PyTypeObject PySocketSockType = { . . . 0, /* set below / / tpalloc */ PySocketSocknew, /* tpnew */ 0, /* set below / / tpfree */ }; /* buried in initsocket */ PySocketSockType.tpalloc = PyTypeGenericAlloc; PySocketSockType.tpfree = PyObjectDel; This trick ensures that the static type object is never freed.
Um, I think you'll find this is because PyType_GenericAlloc & _PyObject_Del aren't compile-time constants when _socket is dynamically linked (they're defined in a different dll).
Cheers, M.
--
so python will fork if activestate starts polluting it? I find it more relevant to speculate on whether Python would fork if the merpeople start invading our cities riding on the backs of giant king crabs. -- Brian Quinlan, comp.lang.python
- Previous message: [Python-Dev] A little GC confusion
- Next message: [Python-Dev] A little GC confusion
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]