New submission from STINNER Victor <vstin...@redhat.com>:

CPython has been created in 1990. In 1990, it made sense to use C macros. But 
nowadays, inlined functions can be used instead:

"Python versions greater than or equal to 3.6 use C89 with several select C99 
features: (...) static inline functions"
https://www.python.org/dev/peps/pep-0007/#c-dialect

I propose to convert 4 macros to inlined functions:

* PyObject_INIT(), PyObject_INIT_VAR()
* _Py_NewReference(), _Py_ForgetReference()

Advantages:

* Functions use regular C syntax
* No more corner cases ("traps") of macros
* Function arguments have a type

Drawbacks:

* Require a specific type can introduce compiler warnings if the caller doesn't 
pass the proper type (PyObject* or PyVarObject*). _Py_NewReference() and 
_Py_ForgetReference() seem to be properly used, but not PyObject_INIT() and 
PyObject_INIT_VAR().

The two attached PRs implements these changes.

----------
components: Interpreter Core
messages: 328367
nosy: vstinner
priority: normal
severity: normal
status: open
title: Convert PyObject_INIT() and _Py_NewReference() to inlined functions
versions: Python 3.8

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue35059>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

  • ... STINNER Victor
    • ... STINNER Victor
    • ... STINNER Victor
    • ... STINNER Victor
    • ... STINNER Victor
    • ... STINNER Victor
    • ... Aaron Hall
    • ... Benjamin Peterson
    • ... STINNER Victor
    • ... శ్రీనివాస్ రెడ్డి తాటిపర్తి
    • ... STINNER Victor

Reply via email to