On Mon, Nov 26, 2018 at 6:12 PM Eric V. Smith <e...@trueblade.com> wrote:
> I thought the important part of the proposal was to have multiple
> PyHandles that point to the same PyObject (you couldn't "directly
> compare handles with each other to learn about object identity"). But
> I'll admit I'm not sure why this would be a win. Then of course they
> couldn't be regular pointers.

Whenever PyPy passes an object from PyPy -> C, then it has to invent a
"PyObject*" to represent the PyPy object. 0.1% of the time, the C code
will use C pointer comparison to implement an "is" check on this
PyObject*. But PyPy doesn't know which 0.1% of the time this will
happen, so 100% of the time an object goes from PyPy -> C, PyPy has to
check and update some global intern table to figure out whether this
particular object has ever made the transition before and use the same
PyObject*. 99.9% of the time, this is pure overhead, and it slows down
one of *the* most common operations C extension code does. If C
extensions checked object identity using some explicit operation like
PyObject_Is() instead of comparing pointers, then PyPy could defer the
expensive stuff until someone actually called PyObject_Is().

Note: numbers are made up and I have no idea how much overhead this
actually adds. But I'm pretty sure this is the basic idea that Armin's
talking about.

-n

-- 
Nathaniel J. Smith -- https://vorpus.org
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to