[issue45476] [C API] Disallow using PyFloat_AS_DOUBLE() as l-value

2021-11-30 Thread STINNER Victor
STINNER Victor added the comment: I wrote PEP 674 "Disallow using macros as l-value" for this change: https://python.github.io/peps/pep-0674/ -- ___ Python tracker ___ __

[issue45476] [C API] Disallow using PyFloat_AS_DOUBLE() as l-value

2021-11-30 Thread STINNER Victor
STINNER Victor added the comment: New changeset 4b97d974ecca9cce532be55410fe851eb9fdcf21 by Victor Stinner in branch 'main': bpo-45476: Disallow using asdl_seq_GET() as l-value (GH-29866) https://github.com/python/cpython/commit/4b97d974ecca9cce532be55410fe851eb9fdcf21 -- _

[issue45476] [C API] Disallow using PyFloat_AS_DOUBLE() as l-value

2021-11-30 Thread STINNER Victor
STINNER Victor added the comment: I created this issue to disallow macros like PyFloat_AS_DOUBLE() and PyDict_GET_SIZE() as l-value. It seems like this change by itself is controversial. I proposed one way to implement this change: convert macros to static inline functions. I didn't expect

[issue45476] [C API] Disallow using PyFloat_AS_DOUBLE() as l-value

2021-11-30 Thread STINNER Victor
Change by STINNER Victor : -- pull_requests: +28092 pull_request: https://github.com/python/cpython/pull/29866 ___ Python tracker ___ __

[issue45476] [C API] Disallow using PyFloat_AS_DOUBLE() as l-value

2021-11-30 Thread STINNER Victor
STINNER Victor added the comment: New changeset c19c3a09618ac400538ee412f84be4c1196c7bab by Victor Stinner in branch 'main': bpo-45476: Add _Py_RVALUE() macro (GH-29860) https://github.com/python/cpython/commit/c19c3a09618ac400538ee412f84be4c1196c7bab -- ___

[issue45476] [C API] Disallow using PyFloat_AS_DOUBLE() as l-value

2021-11-30 Thread STINNER Victor
Change by STINNER Victor : -- pull_requests: +28087 pull_request: https://github.com/python/cpython/pull/29860 ___ Python tracker ___ __

[issue45476] [C API] Disallow using PyFloat_AS_DOUBLE() as l-value

2021-11-29 Thread STINNER Victor
STINNER Victor added the comment: PyBytes_AS_STRING() and PyByteArray_AS_STRING() are used to modify string characters, but not used directly as l-value. Search in PyPI top 5000 packages: $ ./search_pypi_top_5000.sh '(PyByteArray|PyBytes)_AS_.*[^!<>=]=[^=]' pypi-top-5000_2021-08-17/plyvel-1.

[issue45476] [C API] Disallow using PyFloat_AS_DOUBLE() as l-value

2021-11-25 Thread STINNER Victor
STINNER Victor added the comment: I decided to exclude macros which can be used as l-value from the PEP 670, since the motivation to disallow using them as l-value is different, and I prefer to restrict PEP 670 scope. Disallowing using macros as l-value is more about hide implementation deta

[issue45476] [C API] Disallow using PyFloat_AS_DOUBLE() as l-value

2021-11-15 Thread Erlend E. Aasland
Change by Erlend E. Aasland : -- nosy: +erlendaasland ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https:/

[issue45476] [C API] Disallow using PyFloat_AS_DOUBLE() as l-value

2021-11-15 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: On 15.11.2021 10:54, STINNER Victor wrote: > > I don't understand what you are trying to prove about compilers not inlining > when you explicitly ask them... not to inline. I'm not trying to prove anything, Victor. I'm only stating the fact that by swit

[issue45476] [C API] Disallow using PyFloat_AS_DOUBLE() as l-value

2021-11-15 Thread STINNER Victor
STINNER Victor added the comment: I don't understand what you are trying to prove about compilers not inlining when you explicitly ask them... not to inline. The purpose of the -O0 option is to minimize the build time, with a trade-off: don't expect the built executable to be fast. If you ca

[issue45476] [C API] Disallow using PyFloat_AS_DOUBLE() as l-value

2021-11-15 Thread STINNER Victor
STINNER Victor added the comment: I wrote PEP 670 "Convert macros to functions in the Python C API" for this issue: https://www.python.org/dev/peps/pep-0670/ -- ___ Python tracker __

[issue45476] [C API] Disallow using PyFloat_AS_DOUBLE() as l-value

2021-11-15 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: On 15.11.2021 08:54, Oleg Iarygin wrote: > > Oleg Iarygin added the comment: > > Marc-Andre: >> Inlining is something that is completely under the control of the > used compilers. Compilers are free to not inline function marked for > inlining [...] > >

[issue45476] [C API] Disallow using PyFloat_AS_DOUBLE() as l-value

2021-11-14 Thread Oleg Iarygin
Oleg Iarygin added the comment: Marc-Andre: > Inlining is something that is completely under the control of the used compilers. Compilers are free to not inline function marked for inlining [...] I checked the following C snippet on gcc.godbolt.org using GCC 4.1.2 and Clang 3.0.0 with /-O0/-O

[issue45476] [C API] Disallow using PyFloat_AS_DOUBLE() as l-value

2021-10-15 Thread STINNER Victor
STINNER Victor added the comment: I created bpo-45490: "[meta][C API] Avoid C macro pitfalls and usage of static inline functions" to discuss macros and static inline functions more generally. -- ___ Python tracker

[issue45476] [C API] Disallow using PyFloat_AS_DOUBLE() as l-value

2021-10-15 Thread STINNER Victor
Change by STINNER Victor : -- title: [C API] Convert "AS" functions, like PyFloat_AS_DOUBLE(), to static inline functions -> [C API] Disallow using PyFloat_AS_DOUBLE() as l-value ___ Python tracker _