wrapping C pointers

zde spamtrap at bigfoot.com
Mon Jan 12 06:56:00 EST 2004


Hi,

What's the preferred way to wrap handles to C structures in python?
(opaque 32-bit pointers with LSBs=00, that python should never deref)

Convert directly to PyLong? (seems most natural, although python longs
are quite heavy-weight).

Shift right and convert to PyInt? (might result in a bit smaller & faster
python object, but does it really pay off?)

Convert to hexadecimal string? (looks horrible, but SWIG uses that
by default, and the author claims it's faster than embedding the pointer
inside CObjects. (?!?)

CObject? Would provide type information + simple-to-add C methods, but
I don't really need that right now, especially if it's slower than
hexadecimal strings..

Anyone ran some tests? What python types people use in their wrappers?
Thanks..

--
Zdenek




More information about the Python-list mailing list