subclass PyDictObject -- any gotchas?
castironpi at gmail.com
Thu Jan 22 17:17:50 CET 2009
On Jan 22, 7:49 am, Aaron Brady <castiro... at gmail.com> wrote:
> Hello all,
> I am trying to create a mapping class similar to the base dictionary,
> but with some added behaviors that affect pointers on a low level. I
> have a bare-bones version I compiled with MinGW, and it is working! I
> want to know if there is anything that is going to bite me later, when
> I start adding real behavior: for example, times when my overrides
> won't get called, shortcuts, better macros, etc.
> Later on, I will be altering the 'ma_table' field from one call to
> another, overriding most of PyDict_Type's methods with before-and-
> after code, adding synchronization, and copying-and-pasting memory
> allocation code from 'dictobject.c' directly in, since I need the
> object to be at specific addresses. Anything I need to beware of?
> Any reason it might be infeasible?
> 108 lines, please snip on reply.
I would also like to know if there is any chance my subclass can use
the native garbage collection. For instance, if I could write my own
PyObject_MALLOC, then I could use _PyObject_GC_New. It doesn't look
promising, since the stuff is all so hard-coded. For instance,
'_PyObject_GC_Malloc' uses some module-level variables that make it
impossible to duplicate the code, since they are out of scope from my
code. What do you think? Is it possible?
More information about the Python-list