Hi,

Thanks for looking into my PEP 674!

I don't understand well why Py_SIZE() cannot be changed until
Py_SET_SIZE() is available on all supported Python versions (so
affected projects don't have to add a compatibility code), whereas
it's ok to require a compatibility code to keep support for Python 3.8
and older for the approved Py_TYPE() change (Py_SET_TYPE was added to
Python 3.9).

Many projects affected by the Py_SIZE() change are already affected by
the Py_TYPE() change, and so need a compatibility code anyway: 33%
(5/15) of affected projects are affected by Py_SIZE() and Py_TYPE()
changes (see below).

Not changing Py_SIZE() now avoids adding a compatibility code to the
33% (5/15) of affected projects only affected by the Py_SIZE() change.

Either changing Py_TYPE() *and* Py_SIZE(), or none, would make more
sense to me. Well, I would prefer to change both, since the work is
already done. The change is already part of Python 3.11 and all
projects known to be afffected are already fixed. And the Py_TYPE()
change was already approved.

--

The Py_TYPE() change requires a compatibility code to get
Py_SET_TYPE() on Python 3.8 and older, use pythoncapi_compat.h or add:

#if PY_VERSION_HEX < 0x030900A4
# define Py_SET_TYPE(obj, type) ((Py_TYPE(obj) = (type)), (void)0)
#endif

The Py_SIZE() change requires a similar compatibility code. For
example, boost defines Py_SET_TYPE() *and* Py_SET_SIZE():

#if PY_VERSION_HEX < 0x030900A4
# define Py_SET_TYPE(obj, type) ((Py_TYPE(obj) = (type)), (void)0)
# define Py_SET_SIZE(obj, size) ((Py_SIZE(obj) = (size)), (void)0)
#endif

--

Affected projects from PEP 674.

Projects affected by Py_SIZE() and Py_TYPE() changes (5):

* guppy3: Py_SET_TYPE(), Py_SET_SIZE(), Py_SET_REFCNT(), use pythoncapi_compat.h
* bitarray: Py_SET_TYPE(), Py_SET_SIZE(), use pythoncapi_compat.h
* mypy: Py_SET_TYPE(), Py_SET_SIZE(), use pythoncapi_compat.h
* numpy: Py_SET_TYPE(), Py_SET_SIZE(), custom compatibility code
* boost: Py_SET_TYPE(), Py_SET_SIZE(), custom compatibility code

Projects only affected by the Py_SIZE() change (5):

* python-snappy: Py_SET_SIZE(), use pythoncapi_compat.h
* recordclass: use custom py_refcnt() and py_set_size() macros
* Cython: Py_SET_SIZE(), Py_SET_REFCNT(), custom compatibility code
* immutables: Py_SET_SIZE(), use pythoncapi_compat.h
* zstd: Py_SET_SIZE(), use pythoncapi_compat.h

Projects only affected by Py_TYPE() change (5):

* datatable: Py_SET_TYPE(), Py_SET_REFCNT(), use pythoncapi_compat.h
* mercurial: Py_SET_TYPE(), use pythoncapi_compat.h
* pycurl: Py_SET_TYPE(), custom compatibility code
* duplicity: Py_SET_TYPE(), test PY_MAJOR_VERSION and
PY_MINOR_VERSION, or use Py_TYPE() as l-value
* gobject-introspection: Py_SET_TYPE(), custom compatibility code

These examples don't count the larger number of affected projects
using Cython which only need to re-run Cython to use Py_SET_REFCNT(),
Py_SET_TYPE() and Py_SET_SIZE().

I would like to add that 100% of the top 5000 PyPI projects are
already fixed for PEP 674, but 26 projects need a release including a
fix (which will likely happend before Python 3.11 final release).

Victor
-- 
Night gathers, and now my watch begins. It shall not end until my death.
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/YQOSKYGDGRKBAFYW2AJQIIMYMQHALUOQ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to