wrapping C pointers

Z

zde

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..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,175
Messages
2,570,942
Members
47,491
Latest member
mohitk

Latest Threads

Top