Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

MAINT: refactorscalartypes.c.src to pure C++#30361

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
scratchmex wants to merge26 commits intonumpy:main
base:main
Choose a base branch
Loading
fromscratchmex:gh-29528--scalartypes
Open
Changes from1 commit
Commits
Show all changes
26 commits
Select commitHold shift + click to select a range
370daf3
remove begin repeat and use macros
scratchmexDec 3, 2025
df1167e
Merge remote-tracking branch 'upstream/main' into gh-29528--scalartypes
scratchmexDec 3, 2025
dba6e5a
use macros for bit count and unary defs
scratchmexDec 3, 2025
9e7ec22
migrate scalartypes.c.src to C++ (for now scalartypes.cpp.src)
scratchmexDec 3, 2025
d3efc87
solve all writable-strings warnings
scratchmexDec 3, 2025
69fa910
learning struct factories at top level and compile time. introduce `m…
scratchmexDec 3, 2025
b09125a
remove all designated initializers to make MSVC happy
scratchmexDec 4, 2025
3ed09f5
missing extern "C" for MSVC
scratchmexDec 4, 2025
86096b3
convert all pymethoddefs and its methods to c++ templates (when possi…
scratchmexDec 4, 2025
3c1499b
refactor buffer protocol to use c++ templates
scratchmexDec 4, 2025
d0eafef
remove constexpr to make MSVC happy (again)
scratchmexDec 5, 2025
99a6b4d
Merge remote-tracking branch 'upstream/main'
scratchmexDec 5, 2025
5a3a5a7
refactor str and repr impls to use c++ templates
scratchmexDec 5, 2025
78201cb
fix py funcs signature to have all make factories constexpr
scratchmexDec 5, 2025
2f158c3
expand all templating from initialize_numeric_types to explicit defs
scratchmexDec 5, 2025
09264f0
simplify (a lot) tp_as_number definitions
scratchmexDec 6, 2025
86f7ba9
expand some generic method definitions
scratchmexDec 6, 2025
cf47013
refactor dunder index and hash to use c++ templates
scratchmexDec 6, 2025
7ea0cfb
expand scalar kinds table
scratchmexDec 6, 2025
0e0d841
refactor scalarobj definitions with struct factory and c++ templates
scratchmexDec 6, 2025
3af9ac3
refactor dunder new impls to use c++ templates
scratchmexDec 6, 2025
029e65c
rename scalartypes.cpp.src to scalartypes.cpp (pure c++ YEAH)
scratchmexDec 6, 2025
c233cb5
fix GCC conflicts
scratchmexDec 6, 2025
d3d85c9
use a workaround for old compilers that have ill-formed static_assert
scratchmexDec 6, 2025
140a199
run clang-format (not all changes)
scratchmexDec 7, 2025
b13e002
missing constexpr
scratchmexDec 7, 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
PrevPrevious commit
NextNext commit
learning struct factories at top level and compile time. introduce `m…
…ake_pyarr_type`
  • Loading branch information
@scratchmex
scratchmex committedDec 3, 2025
commit69fa910119bef645c28439d5122f18b074fd19cb
36 changes: 18 additions & 18 deletionsnumpy/_core/src/multiarray/scalartypes.cpp.src
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -68,24 +68,24 @@ NPY_NO_EXPORT PyTypeObject PyTimeIntegerArrType_Type;
* single inheritance)
*/

#define DEF_PYARRTYPE(PyTypeName,tp_name_) \
NPY_NO_EXPORT PyTypeObject PyTypeName = { \
PyVarObject_HEAD_INIT(NULL, 0) \
.tp_name = #tp_name_, \
.tp_basicsize =sizeof(PyObject), \
};

DEF_PYARRTYPE(PyNumberArrType_Type, numpy.number)
DEF_PYARRTYPE(PyIntegerArrType_Type, numpy.integer)
DEF_PYARRTYPE(PySignedIntegerArrType_Type,numpy.signedinteger)
DEF_PYARRTYPE(PyUnsignedIntegerArrType_Type,numpy.unsignedinteger)
DEF_PYARRTYPE(PyInexactArrType_Type,numpy.inexact)
DEF_PYARRTYPE(PyFloatingArrType_Type,numpy.floating)
DEF_PYARRTYPE(PyComplexFloatingArrType_Type,numpy.complexfloating)
DEF_PYARRTYPE(PyFlexibleArrType_Type,numpy.flexible)
DEF_PYARRTYPE(PyCharacterArrType_Type,numpy.character)

#undef DEF_PYARRTYPE
constexpr PyTypeObject make_pyarr_type(const char*tp_name_){
// we initialize in-line because in MSVC:
// error C7555: use of designated initializers requires at least '/std:c++20'
PyTypeObject t = { PyVarObject_HEAD_INIT(NULL, 0) };
t.tp_name =tp_name_;
t.tp_basicsize = sizeof(PyObject);
return t;
}

PyTypeObject PyNumberArrType_Type = make_pyarr_type("numpy.number");
PyTypeObject PyIntegerArrType_Type = make_pyarr_type("numpy.integer");
PyTypeObject PySignedIntegerArrType_Type = make_pyarr_type("numpy.signedinteger");
PyTypeObject PyUnsignedIntegerArrType_Type = make_pyarr_type("numpy.unsignedinteger");
PyTypeObject PyInexactArrType_Type = make_pyarr_type("numpy.inexact");
PyTypeObject PyFloatingArrType_Type = make_pyarr_type("numpy.floating");
PyTypeObject PyComplexFloatingArrType_Type = make_pyarr_type("numpy.complexfloating");
PyTypeObject PyFlexibleArrType_Type = make_pyarr_type("numpy.flexible");
PyTypeObject PyCharacterArrType_Type = make_pyarr_type("numpy.character");

static PyObject *
gentype_alloc(PyTypeObject *type, Py_ssize_t nitems)
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp