Define _Py_TYPEOF on MSVC and other compilers supporting __typeof__
#121647
Labels
interpreter-core
(Objects, Python, Grammar, and Parser dirs)
OS-windows
type-feature
A feature request or enhancement


Feature or enhancement
Proposal:
Recently, MSVC implemented
__typeof__, which currently is defined as_Py_TYPEOFonly on GCC and Clang.cpython/Include/pyport.h
Lines 553 to 560 in 65feded
The only users of
_Py_TYPEOFare macrosPy_CLEAR(),Py_SETREF()andPy_XSETREF().If
_Py_TYPEOFis not defined, these macros fall back to slightly uglier implementations withmemcpycalls.cpython/Include/refcount.h
Lines 421 to 442 in 65feded
The proposal is to define
_Py_TYPEOFon:__typeof____typeof__typeofor C++11decltypeBy defining
_Py_TYPEOF, uses ofPy_CLEAR(),Py_SETREF()andPy_XSETREF()are switched to the_Py_TYPEOFimplementation; on these compilers, the benefits would be:memcpyas seen inmemcpy()usage without#include <string.h>inpwdmodule.c#121617Additionally, this removes a differing detail between MSVC and GCC/Clang builds, which should be generally desirable.
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
Linked PRs
The text was updated successfully, but these errors were encountered: