10000 MNT: Reorganize non-constant global statics into structs by ngoldbaum · Pull Request #26607 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

MNT: Reorganize non-constant global statics into structs #26607

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

Merged
merged 23 commits into from
Jun 19, 2024
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
baee891
MNT: move interned strings into a single global struct
ngoldbaum May 30, 2024
69075c1
MNT: move cached imports into a global struct
ngoldbaum May 21, 2024
e5c1bd6
MNT: move cpu dispatch registry into global data struct
ngoldbaum May 30, 2024
7719cf2
MNT: move ndarray.__array_*__ references to global data struct
ngoldbaum May 30, 2024
3cbb68d
MNT: move sys.flags.optimize cache to global data struct
ngoldbaum May 30, 2024
2ffcc71
MNT: set up tuple for truediv in global data struct
ngoldbaum May 30, 2024
d2ca21b
MNT: move unpack_bits LUT into global static struct
ngoldbaum May 30, 2024
a1f7200
MNT: move references to int(1) and int(0) to global static struct
ngoldbaum May 30, 2024
26c243d
MNT: move initialization of global ArrayMethods to module initialization
ngoldbaum May 30, 2024
536e5fb
MNT: move initialization of global tuples to global data struct
ngoldbaum May 30, 2024
0c22126
MNT: move default extobj contextvar to global data dict
ngoldbaum May 30, 2024
90b1f38
MNT: move PyArray_SetStringFunction internals into global data struct
ngoldbaum May 30, 2024
6a296c4
BUG: remove questionable static initialization of an array object
ngoldbaum May 30, 2024
398f095
MNT: split global data struct into two structs
ngoldbaum Jun 3, 2024
8f84875
MNT: add PyArrayMethodObject caches to static data struct
ngoldbaum Jun 5, 2024
402a83c
MNT: move some thread-unsafe state in thread-unsafe state struct
ngoldbaum Jun 5, 2024
e43275a
MNT: make data structs static instead of heap-allocated
ngoldbaum Jun 5, 2024
b706536
MNT: apply sebastian's refactoring suggestions
ngoldbaum Jun 6, 2024
c237038
MNT: move static data structs into their own file
ngoldbaum Jun 7, 2024
98ae65d
MNT: Add more global state I missed to the thread_unsafe_state struct
ngoldbaum Jun 7, 2024
a334ddc
MNT: verify all entries in npy_interned_str and npy_static_pydata are…
ngoldbaum Jun 11, 2024
9ed317f
Apply suggestions from code review
ngoldbaum Jun 13, 2024
3ae66b1
MAINT: apply more of Sebastian's suggestions
ngoldbaum Jun 13, 2024
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
Prev Previous commit
Next Next commit
Apply suggestions from code review
Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
  • Loading branch information
ngoldbaum and seberg committed Jun 19, 2024
commit 9ed317f202aea1dca17378f0525e7c5b5b40d787
10 changes: 3 additions & 7 deletions numpy/_core/src/multiarray/npy_static_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,17 +156,12 @@ initialize_static_globals(void)

// default_truediv_type_tupS
PyArray_Descr *tmp = PyArray_DescrFromType(NPY_DOUBLE);
if (tmp == NULL) {
return -1;
}

npy_static_pydata.default_truediv_type_tup =
PyTuple_Pack(3, tmp, tmp, tmp);
Py_DECREF(tmp);
if (npy_static_pydata.default_truediv_type_tup == NULL) {
Py_DECREF(tmp);
return -1;
}
Py_DECREF(tmp);

npy_static_pydata.kwnames_is_copy = Py_BuildValue("(s)", "copy");
if (npy_static_pydata.kwnames_is_copy == NULL) {
Expand Down Expand Up @@ -225,6 +220,8 @@ initialize_static_globals(void)

return 0;
}


/*
* Verifies all entries in npy_interned_str and npy_static_pydata are
* non-NULL.
Expand All @@ -234,7 +231,6 @@ initialize_static_globals(void)
* items that are initialized late in module initialization but they
* should all be initialized by the time this function is called.
*/

NPY_NO_EXPORT int
verify_static_structs_initialized(void) {
// verify all entries in npy_interned_str are filled in
Expand Down
0