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/2018-November/155812.html below:

[Python-Dev] C API changes

[Python-Dev] C API changesArmin Rigo armin.rigo at gmail.com
Sun Nov 25 00:15:03 EST 2018
Hi Stefan,

On Sat, 24 Nov 2018 at 22:17, Stefan Behnel <stefan_ml at behnel.de> wrote:
> Couldn't this also be achieved via reference counting? Count only in C
> space, and delete the "open object" when the refcount goes to 0?

The point is to remove the need to return the same handle to C code if
the object is the same one.  This saves one of the largest costs of
the C API emulation, which is looking up the object in a big
dictionary to know if there is already a ``PyObject *`` that
corresponds to it or not---for *all* objects that go from Python to C.

Once we do that, then there is no need for a refcount any more.  Yes,
you could add your custom refcount code in C, but in practice it is
rarely done.  For example, with POSIX file descriptors, when you would
need to "incref" a file descriptor, you instead use dup().  This gives
you a different file descriptor which can be closed independently of
the original one, but they both refer to the same file.


A bientôt,

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