Skip to content

Commit

Permalink
Py_TYPE
Browse files Browse the repository at this point in the history
  • Loading branch information
vstinner committed May 28, 2019
1 parent 47f04d4 commit 13ca056
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
14 changes: 11 additions & 3 deletions doc/bad_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,17 @@ Hugh Fisher summarized:
and incur a performance hit, to eliminate a rare bug from badly written
code.

See the discussion on capi-sig: `Open questions about borrowed reference.
<https://mail.python.org/mm3/archives/list/capi-sig@python.org/thread/V5EMBIIJFJGJGBQPLCFFXCHAUFNTA45H/>`_
(Sept 2018).
Discussions:

* `[Python-Dev] bpo-34595: How to format a type name?
<https://mail.python.org/pipermail/python-dev/2018-September/155150.html>`_
(Sept 2018)
* capi-sig: `Open questions about borrowed reference.
<https://mail.python.org/mm3/archives/list/capi-sig@python.org/thread/V5EMBIIJFJGJGBQPLCFFXCHAUFNTA45H/>`_
(Sept 2018).


See also :ref:`Opaque PyObject structure <opaque-pyobject>`.


Duplicated functions
Expand Down
4 changes: 3 additions & 1 deletion doc/opaque_pyobject.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. _opaque-pyobject:

=========================
Opaque PyObject structure
=========================
Expand All @@ -24,7 +26,7 @@ The issue is that ``obj->ob_type`` is accessed directly. It prevents to
implement :ref:`Tagged pointers <tagged-pointer>` for example.

By the way, ``Py_TYPE()`` returns a :ref:`borrowed reference <borrowed-ref>`
which is another kind of problem.
which is another kind of problem. See :ref:`Py_TYPE() corner case <py-type>`.

In the long term, ``PyObject`` structure should be opaque. Accessing
``ob_refcnt`` and ``ob_type`` fields should always go through functions.
Expand Down

0 comments on commit 13ca056

Please sign in to comment.