Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
82d1259
Brandt's changes
Fidget-Spinner Aug 21, 2025
3248658
Hulon's and mine changes
Fidget-Spinner Aug 21, 2025
9ac430d
push stackrefs into tstate
Fidget-Spinner Aug 21, 2025
085c1d7
Fix last few remaining problems
Fidget-Spinner Aug 21, 2025
0b12f2e
fix handling of recursion
Fidget-Spinner Aug 24, 2025
acf48f5
Changes by Chris to support clang-cl
Fidget-Spinner Oct 11, 2025
35e96c1
Make the restrict MSVC only for now
Fidget-Spinner Oct 11, 2025
d7737e9
Merge remote-tracking branch 'upstream/main' into msvc-tailcall-take-two
Fidget-Spinner Oct 11, 2025
86f19cf
Change restricts to MSVC only
Fidget-Spinner Oct 11, 2025
40013cc
📜🤖 Added by blurb_it.
blurb-it[bot] Oct 11, 2025
48db59e
Reduce diff
Fidget-Spinner Oct 11, 2025
bc9d23c
Merge branch 'msvc-tailcall-take-two' of github.com:Fidget-Spinner/cp…
Fidget-Spinner Oct 11, 2025
19e02c2
Work around specialization
Fidget-Spinner Oct 11, 2025
66ec774
Fix VS 2026
Fidget-Spinner Oct 11, 2025
50f8ff7
fix a typo
Fidget-Spinner Oct 11, 2025
5d908b4
Move to macros to internal header
Fidget-Spinner Oct 11, 2025
0786133
Merge branch 'msvc-tailcall-take-two' of github.com:Fidget-Spinner/cp…
Fidget-Spinner Oct 11, 2025
e699d40
Reduce number of restricts
Fidget-Spinner Oct 13, 2025
66d6c39
Merge branch 'msvc-tailcall-take-two' of https://github.com/Fidget-Sp…
Fidget-Spinner Oct 13, 2025
5584fec
Reduce restrict use even more, reduce usage
Fidget-Spinner Oct 13, 2025
7eeeaa8
Apply Chris' changes
Fidget-Spinner Oct 23, 2025
6f3d525
Merge remote-tracking branch 'upstream/main' into msvc-tailcall-take-two
Fidget-Spinner Nov 4, 2025
81618e2
Merge remote-tracking branch 'upstream/main' into msvc-tailcall-take-two
Fidget-Spinner Nov 11, 2025
2008d1d
Use choco for now to get VS 2026
Fidget-Spinner Nov 11, 2025
7c84388
Update tail-call.yml
Fidget-Spinner Nov 11, 2025
68b41cf
Update tail-call.yml
Fidget-Spinner Nov 11, 2025
c7316fc
Update tail-call.yml
Fidget-Spinner Nov 11, 2025
9214d5b
Update tail-call.yml
Fidget-Spinner Nov 11, 2025
52c6f9c
Update tail-call.yml
Fidget-Spinner Nov 11, 2025
34d98d3
Update tail-call.yml
Fidget-Spinner Nov 11, 2025
7ec626e
Update tail-call.yml
Fidget-Spinner Nov 11, 2025
ad1c5a2
Update tail-call.yml
Fidget-Spinner Nov 11, 2025
4155337
Update tail-call.yml
Fidget-Spinner Nov 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Include/internal/pycore_ceval.h
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,24 @@ _PyForIter_VirtualIteratorNext(PyThreadState* tstate, struct _PyInterpreterFrame
/* Special counterparts of ceval functions for performance reasons */
PyAPI_FUNC(int) _PyEval_Mapping_GetOptionalItem(PyObject *obj, PyObject *key, PyObject **result);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the only difference the restrict annotation?
We could just add the annotation to PyMapping_GetOptionalItem the result pointer can never alias the other parameters.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. We can't because PyMapping_GetOptionalItem is part of the public API, and we can't change the signature of it.

Copy link
Copy Markdown
Member

@markshannon markshannon Oct 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We aren't changing the signature, just telling the compiler than one of its parameters can't alias the others.
I'm surprised we need to do this anyway. I would have thought that strict aliasing already tells MSVC that they can't alias.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is, that strict aliasing can't help here, since in

PyMapping_GetOptionalItem(PyObject *obj, PyObject *key, PyObject **result)

all parameters are of type PyObject. And by using restrict we tell the compiler that "we assure you, that none of these PyObjects point to the same memory", and if we brake that contract, UB kicks in.


#if defined(_MSC_VER) && !defined(__clang__) && _Py_TAIL_CALL_INTERP
# define Py_NO_INLINE_MSVC_TAILCALL Py_NO_INLINE
#else
# define Py_NO_INLINE_MSVC_TAILCALL
#endif

#if defined(_MSC_VER) && !defined(__clang__)
# define Py_MSVC_RESTRICT restrict
#else
# define Py_MSVC_RESTRICT
#endif

// Just a scope. Hints to the programmer
// That any local variable defined within this block MUST
// not escape from the current definition.
# define Py_BEGIN_LOCALS_MUST_NOT_ESCAPE() {
# define Py_END_LOCALS_MUST_NOT_ESCAPE() }

#ifdef __cplusplus
}
#endif
Expand Down
18 changes: 0 additions & 18 deletions Include/pyport.h
Original file line number Diff line number Diff line change
Expand Up @@ -385,24 +385,6 @@ extern "C" {
# define Py_NO_INLINE
#endif

#if defined(_MSC_VER) && !defined(__clang__) && _Py_TAIL_CALL_INTERP
# define Py_NO_INLINE_MSVC_TAILCALL Py_NO_INLINE
#else
# define Py_NO_INLINE_MSVC_TAILCALL
#endif

#if defined(_MSC_VER) && !defined(__clang__)
# define Py_MSVC_RESTRICT restrict
#else
# define Py_MSVC_RESTRICT
#endif

// Just a scope. Hints to the programmer
// That any local variable defined within this block MUST
// not escape from the current definition.
# define Py_BEGIN_LOCALS_MUST_NOT_ESCAPE {
# define Py_END_LOCALS_MUST_NOT_ESCAPE }

#include "exports.h"

#ifdef Py_LIMITED_API
Expand Down