On 05/16/2012 10:11 AM, Nick Coghlan wrote:
Use PyObject_HasAttr, just as people use hasattr() for ducktyping in Python.

In the Cython wrap-function-pointers case we really want performance comparable to C, so we couldn't do the whole thing.

But I guess we could intern some char* (somehow), pass that to tp_getattr, and then cast the returned PyObject* (which would not be a PyObject*) to a custom struct. As long as the interned strings can never be reached from Python that's almost safe. It's still slight abuse of tp_getattr.

As I said, if we didn't worry about performance we'd just retrieve capsules through attributes.

Dag



If you want something more structured, use Abstract Base Classes,
that's what they're for.

Cheers,
Nick.


_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to