[Python-Dev] C API changes

Chris Angelico rosuav at gmail.com
Thu Nov 29 01:19:28 EST 2018


On Thu, Nov 29, 2018 at 5:10 PM Armin Rigo <armin.rigo at gmail.com> wrote:
> PS: on CPython could use ``typedef struct { PyObject *_obj; }
> PyHandle;``.  This works like a pointer, but you can't use ``==`` to
> compare them.

And then you could have a macro or inline function to compare them,
simply by looking at that private member, and it should compile down
to the exact same machine code as comparing the original pointers
directly. It'd be a not-unreasonable migration path, should you want
to work that way - zero run-time cost.

ChrisA


More information about the Python-Dev mailing list