-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
ENH: add locking around initializing the argparse cache #26430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,13 @@ | |
#include <Python.h> | ||
#include "numpy/ndarraytypes.h" | ||
|
||
#ifdef __STDC_NO_ATOMICS__ | ||
#define atomic_int volatile int | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Caveat: this is "good enough" for x86 MSVC and also Window's "ARM64EC" platform target, but not other ARM64 targets on Windows. If we need to support other Windows ARM64 targets, we'll need a bit more work. Hopefully, MSVC will support https://learn.microsoft.com/en-us/cpp/build/reference/volatile-volatile-keyword-interpretation There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for clarifying! We don't test or build wheels for windows ARM64 right now, but I think we might need to support I see
And storing is implemented using e.g. That all seems reasonable to include in NumPy to support this. Even with the experimental atomics support in MSVC 2022, they still set |
||
#else | ||
#include <stdatomic.h> | ||
#endif | ||
|
||
|
||
/* | ||
* This file defines macros to help with keyword argument parsing. | ||
* This solves two issues as of now: | ||
|
@@ -20,18 +27,19 @@ | |
NPY_NO_EXPORT int | ||
PyArray_PythonPyIntFromInt(PyObject *obj, int *value); | ||
|
||
|
||
#define _NPY_MAX_KWARGS 15 | ||
|
||
typedef struct { | ||
int npositional; | ||
int nargs; | ||
int npositional_only; | ||
int nrequired; | ||
atomic_int initialized; | ||
/* Null terminated list of keyword argument name strings */ | ||
PyObject *kw_strings[_NPY_MAX_KWARGS+1]; | ||
} _NpyArgParserCache; | ||
|
||
NPY_NO_EXPORT int init_argparse_mutex(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
/* | ||
* The sole purpose of this macro is to hide the argument parsing cache. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be:
int init_argparse_mutex(void)
?