homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients vstinner
Date 2018年10月24日.14:31:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1540391516.33.0.788709270274.issue35059@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2018年10月24日 14:31:56vstinnersetrecipients: + vstinner
2018年10月24日 14:31:56vstinnersetmessageid: <1540391516.33.0.788709270274.issue35059@psf.upfronthosting.co.za>
2018年10月24日 14:31:56vstinnerlinkissue35059 messages
2018年10月24日 14:31:56vstinnercreate

AltStyle によって変換されたページ (->オリジナル) /