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
Show file tree
Hide file tree
Changes fromall commits
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
2 changes: 1 addition & 1 deletiondoc/source/conf.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -502,7 +502,7 @@ def setup(app):

def _get_c_source_file(obj):
if issubclass(obj, numpy.generic):
return r"_core/src/multiarray/scalartypes.c.src"
return r"_core/src/multiarray/scalartypes.cpp"
elif obj is numpy.ndarray:
return r"_core/src/multiarray/arrayobject.c"
else:
Expand Down
6 changes: 3 additions & 3 deletionsnumpy/_core/arrayprint.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,8 +16,8 @@
# and by Travis Oliphant 2005-8-22 for numpy


# Note: Both scalartypes.c.src and arrayprint.py implement strs for numpy
# scalars but for different purposes. scalartypes.c.src has str/reprs for when
# Note: Both scalartypes.cpp and arrayprint.py implement strs for numpy
# scalars but for different purposes. scalartypes.cpp has str/reprs for when
# the scalar is printed on its own, while arrayprint.py has strs for when
# scalars are printed inside an ndarray. Only the latter strs are currently
# user-customizable.
Expand DownExpand Up@@ -1485,7 +1485,7 @@ def __call__(self, x):
def_void_scalar_to_string(x,is_repr=True):
"""
Implements the repr for structured-void scalars. It is called from the
scalartypes.c.src code, and is placed here because it uses the elementwise
scalartypes.cpp code, and is placed here because it uses the elementwise
formatters defined above.
"""
options=format_options.get().copy()
Expand Down
2 changes: 1 addition & 1 deletionnumpy/_core/code_generators/genapi.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -77,7 +77,7 @@ def get_processor():
join('multiarray','nditer_templ.c.src'),
join('multiarray','number.c'),
join('multiarray','refcount.c'),
join('multiarray','scalartypes.c.src'),
join('multiarray','scalartypes.cpp'),
join('multiarray','scalarapi.c'),
join('multiarray','sequence.c'),
join('multiarray','shape.c'),
Expand Down
2 changes: 1 addition & 1 deletionnumpy/_core/meson.build
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1182,7 +1182,7 @@ src_multiarray = multiarray_gen_headers + [
'src/multiarray/npy_static_data.c',
'src/multiarray/number.c',
'src/multiarray/refcount.c',
src_file.process('src/multiarray/scalartypes.c.src'),
'src/multiarray/scalartypes.cpp',
'src/multiarray/sequence.c',
'src/multiarray/scalarapi.c',
'src/multiarray/shape.c',
Expand Down
9 changes: 9 additions & 0 deletionsnumpy/_core/src/common/npy_longdouble.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
#ifndefNUMPY_CORE_SRC_COMMON_NPY_LONGDOUBLE_H_
#defineNUMPY_CORE_SRC_COMMON_NPY_LONGDOUBLE_H_


#include"npy_config.h"
#include"numpy/ndarraytypes.h"

#ifdef__cplusplus
extern"C" {
#endif

/* Convert a npy_longdouble to a python `long` integer.
*
* Results are rounded towards zero.
Expand All@@ -24,4 +29,8 @@ npy_longdouble_to_PyLong(npy_longdouble ldval);
NPY_VISIBILITY_HIDDENnpy_longdouble
npy_longdouble_from_PyLong(PyObject*long_obj);

#ifdef__cplusplus
}
#endif

#endif/* NUMPY_CORE_SRC_COMMON_NPY_LONGDOUBLE_H_ */
8 changes: 8 additions & 0 deletionsnumpy/_core/src/multiarray/_datetime.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
#ifndefNUMPY_CORE_SRC_MULTIARRAY__DATETIME_H_
#defineNUMPY_CORE_SRC_MULTIARRAY__DATETIME_H_

#ifdef__cplusplus
extern"C" {
#endif

externNPY_NO_EXPORTcharconst*_datetime_strings[NPY_DATETIME_NUMUNITS];
externNPY_NO_EXPORTint_days_per_month_table[2][12];

Expand DownExpand Up@@ -335,4 +339,8 @@ datetime_hash(PyArray_DatetimeMetaData *meta, npy_datetime dt);
NPY_NO_EXPORTnpy_hash_t
timedelta_hash(PyArray_DatetimeMetaData*meta,npy_timedeltatd);

#ifdef__cplusplus
}
#endif

#endif/* NUMPY_CORE_SRC_MULTIARRAY__DATETIME_H_ */
7 changes: 7 additions & 0 deletionsnumpy/_core/src/multiarray/array_api_standard.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
#ifndefNUMPY_CORE_SRC_MULTIARRAY_ARRAY_API_STANDARD_H_
#defineNUMPY_CORE_SRC_MULTIARRAY_ARRAY_API_STANDARD_H_

#ifdef__cplusplus
extern"C" {
#endif

NPY_NO_EXPORTPyObject*
array_device(PyObject*NPY_UNUSED(self),void*NPY_UNUSED(ignored));
Expand All@@ -11,4 +14,8 @@ array_to_device(PyObject *self, PyObject *args, PyObject *kwds);
NPY_NO_EXPORTPyObject*
array_array_namespace(PyObject*NPY_UNUSED(self),PyObject*args,PyObject*kwds);

#ifdef__cplusplus
}
#endif

#endif/* NUMPY_CORE_SRC_MULTIARRAY_ARRAY_API_STANDARD_H_ */
8 changes: 8 additions & 0 deletionsnumpy/_core/src/multiarray/conversion_utils.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,6 +3,10 @@

#include"numpy/ndarraytypes.h"

#ifdef__cplusplus
extern"C" {
#endif

NPY_NO_EXPORTint
PyArray_IntpConverter(PyObject*obj,PyArray_Dims*seq);

Expand DownExpand Up@@ -122,4 +126,8 @@ extern NPY_NO_EXPORT NPY_TLS int evil_global_disable_warn_O4O8_flag;
NPY_NO_EXPORTint
_not_NoValue(PyObject*obj,PyObject**out);

#ifdef__cplusplus
}
#endif

#endif/* NUMPY_CORE_SRC_MULTIARRAY_CONVERSION_UTILS_H_ */
8 changes: 8 additions & 0 deletionsnumpy/_core/src/multiarray/ctors.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
#ifndefNUMPY_CORE_SRC_MULTIARRAY_CTORS_H_
#defineNUMPY_CORE_SRC_MULTIARRAY_CTORS_H_

#ifdef__cplusplus
extern"C" {
#endif

externNPY_NO_EXPORTconstchar*npy_no_copy_err_msg;


Expand DownExpand Up@@ -135,4 +139,8 @@ NPY_NO_EXPORT PyObject *
PyArray_Empty_int(intnd,npy_intpconst*dims,PyArray_Descr*descr,
PyArray_DTypeMeta*dtype,intis_f_order);

#ifdef__cplusplus
}
#endif

#endif/* NUMPY_CORE_SRC_MULTIARRAY_CTORS_H_ */
8 changes: 8 additions & 0 deletionsnumpy/_core/src/multiarray/dragon4.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -41,6 +41,10 @@

#include"numpy/arrayscalars.h"

#ifdef__cplusplus
extern"C" {
#endif

/* Half binary format */
#defineNPY_HALF_BINFMT_NAME IEEE_binary16

Expand DownExpand Up@@ -135,4 +139,8 @@ Dragon4_Scientific(PyObject *obj, DigitMode digit_mode, int precision,
intmin_digits,intsign,TrimModetrim,intpad_left,
intexp_digits);

#ifdef__cplusplus
}
#endif

#endif/* NUMPY_CORE_SRC_MULTIARRAY_DRAGON4_H_ */
8 changes: 8 additions & 0 deletionsnumpy/_core/src/multiarray/flagsobject.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
#ifndefNUMPY_CORE_SRC_FLAGSOBJECT_H_
#defineNUMPY_CORE_SRC_FLAGSOBJECT_H_

#ifdef__cplusplus
extern"C" {
#endif


/* Array Flags Object */
typedefstructPyArrayFlagsObject {
Expand All@@ -19,4 +23,8 @@ NPY_NO_EXPORT void
PyArray_UpdateFlags(PyArrayObject*ret,intflagmask);


#ifdef__cplusplus
}
#endif

#endif/* NUMPY_CORE_SRC_FLAGSOBJECT_H_ */
8 changes: 8 additions & 0 deletionsnumpy/_core/src/multiarray/mapping.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
#ifndefNUMPY_CORE_SRC_MULTIARRAY_MAPPING_H_
#defineNUMPY_CORE_SRC_MULTIARRAY_MAPPING_H_

#ifdef__cplusplus
extern"C" {
#endif

externNPY_NO_EXPORTPyMappingMethodsarray_as_mapping;

/* Indexing types */
Expand DownExpand Up@@ -184,4 +188,8 @@ NPY_NO_EXPORT PyObject *
PyArray_MapIterArrayCopyIfOverlap(PyArrayObject*a,PyObject*index,
intcopy_if_overlap,PyArrayObject*extra_op);

#ifdef__cplusplus
}
#endif

#endif/* NUMPY_CORE_SRC_MULTIARRAY_MAPPING_H_ */
8 changes: 8 additions & 0 deletionsnumpy/_core/src/multiarray/multiarraymodule.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
#ifndefNUMPY_CORE_SRC_MULTIARRAY_MULTIARRAYMODULE_H_
#defineNUMPY_CORE_SRC_MULTIARRAY_MULTIARRAYMODULE_H_

#ifdef__cplusplus
extern"C" {
#endif

/*
* A struct storing thread-unsafe global state for the _multiarray_umath
* module. We should refactor so the global state is thread-safe,
Expand DownExpand Up@@ -85,4 +89,8 @@ NPY_VISIBILITY_HIDDEN extern npy_thread_unsafe_state_struct npy_thread_unsafe_st
NPY_NO_EXPORTint
get_legacy_print_mode(void);

#ifdef__cplusplus
}
#endif

#endif/* NUMPY_CORE_SRC_MULTIARRAY_MULTIARRAYMODULE_H_ */
8 changes: 8 additions & 0 deletionsnumpy/_core/src/multiarray/npy_buffer.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
#ifndefNUMPY_CORE_SRC_MULTIARRAY_NPY_BUFFER_H_
#defineNUMPY_CORE_SRC_MULTIARRAY_NPY_BUFFER_H_

#ifdef__cplusplus
extern"C" {
#endif

externNPY_NO_EXPORTPyBufferProcsarray_as_buffer;

NPY_NO_EXPORTint
Expand All@@ -12,4 +16,8 @@ _descriptor_from_pep3118_format(char const *s);
NPY_NO_EXPORTint
void_getbuffer(PyObject*obj,Py_buffer*view,intflags);

#ifdef__cplusplus
}
#endif

#endif/* NUMPY_CORE_SRC_MULTIARRAY_NPY_BUFFER_H_ */
8 changes: 8 additions & 0 deletionsnumpy/_core/src/multiarray/number.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
#ifndefNUMPY_CORE_SRC_MULTIARRAY_NUMBER_H_
#defineNUMPY_CORE_SRC_MULTIARRAY_NUMBER_H_

#ifdef__cplusplus
extern"C" {
#endif

typedefstruct {
PyObject*add;
PyObject*subtract;
Expand DownExpand Up@@ -66,4 +70,8 @@ NPY_NO_EXPORT PyObject *
PyArray_GenericAccumulateFunction(PyArrayObject*m1,PyObject*op,intaxis,
intrtype,PyArrayObject*out);

#ifdef__cplusplus
}
#endif

#endif/* NUMPY_CORE_SRC_MULTIARRAY_NUMBER_H_ */
Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp