A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2012-May/119484.html below:

[Python-Dev] C-level duck typing

[Python-Dev] C-level duck typing [Python-Dev] C-level duck typingDag Sverre Seljebotn d.s.seljebotn at astro.uio.no
Wed May 16 10:25:21 CEST 2012
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.
>

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4