8000 MAINT: convert convert_datatype and dtypemeta to c++ by ngoldbaum · Pull Request #28253 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

MAINT: convert convert_datatype and dtypemeta to c++ #28253

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
MAINT: convert convert_datatype and dtypemeta to c++
  • Loading branch information
ngoldbaum committed Jan 31, 2025
commit c004fc072dba485d11db8008f69339b873442061
4 changes: 2 additions & 2 deletions numpy/_core/code_generators/genapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ def get_processor():
join('multiarray', 'common_dtype.c'),
join('multiarray', 'conversion_utils.c'),
join('multiarray', 'convert.c'),
join('multiarray', 'convert_datatype.c'),
join('multiarray', 'convert_datatype.cpp'),
join('multiarray', 'ctors.c'),
join('multiarray', 'datetime.c'),
join('multiarray', 'datetime_busday.c'),
join('multiarray', 'datetime_busdaycal.c'),
join('multiarray', 'datetime_strings.c'),
join('multiarray', 'descriptor.c'),
join('multiarray', 'dlpack.c'),
join('multiarray', 'dtypemeta.c'),
join('multiarray', 'dtypemeta.cpp'),
join('multiarray', 'einsum.c.src'),
join('multiarray', 'public_dtype_api.c'),
join('multiarray', 'flagsobject.c'),
Expand Down
4 changes: 2 additions & 2 deletions numpy/_core/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,7 @@ src_multiarray = multiarray_gen_headers + [
'src/multiarray/common.c',
'src/multiarray/common_dtype.c',
'src/multiarray/convert.c',
'src/multiarray/convert_datatype.c',
'src/multiarray/convert_datatype.cpp',
'src/multiarray/conversion_utils.c',
'src/multiarray/ctors.c',
'src/multiarray/datetime.c',
Expand All @@ -1105,7 +1105,7 @@ src_multiarray = multiarray_gen_headers + [
'src/multiarray/datetime_busdaycal.c',
'src/multiarray/descriptor.c',
'src/multiarray/dlpack.c',
'src/multiarray/dtypemeta.c',
'src/multiarray/dtypemeta.cpp',
'src/multiarray/dragon4.c',
'src/multiarray/dtype_transfer.c',
'src/multiarray/dtype_traversal.c',
Expand Down
8 changes: 8 additions & 0 deletions numpy/_core/src/common/lowlevel_strided_loops.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
/* For PyArray_ macros used below */
#include "numpy/ndarrayobject.h"

#ifdef __cplusplus
extern "C" {
#endif

/*
* NOTE: This API should remain private for the time being, to allow
* for further refinement. I think the 'aligned' mechanism
Expand Down Expand Up @@ -787,4 +791,8 @@ PyArray_EQUIVALENTLY_ITERABLE_OVERLAP_OK(PyArrayObject *arr1, PyArrayObject *arr
stride2 = PyArray_TRIVIAL_PAIR_ITERATION_STRIDE(size2, arr2); \
}

#ifdef __cplusplus
}
#endif

#endif /* NUMPY_CORE_SRC_COMMON_LOWLEVEL_STRIDED_LOOPS_H_ */
8 changes: 8 additions & 0 deletions numpy/_core/src/common/npy_import.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
#include "numpy/npy_common.h"
#include "npy_atomic.h"

#ifdef __cplusplus
extern "C" {
#endif

/*
* Cached references to objects obtained via an import. All of these are
* can be initialized at any time by npy_cache_import_runtime.
Expand Down Expand Up @@ -111,4 +115,8 @@ npy_cache_import_runtime(const char *module, const char *attr, PyObject **obj) {
NPY_NO_EXPORT int
init_import_mutex(void);

#ifdef __cplusplus
}
#endif

#endif /* NUMPY_CORE_SRC_COMMON_NPY_IMPORT_H_ */
7 changes: 7 additions & 0 deletions numpy/_core/src/common/templ_common.h.src
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
#include "numpy/npy_common.h"
#include <assert.h>

#ifdef __cplusplus
extern "C" {
#endif

/**begin repeat
* #name = int, uint, long, ulong,
* longlong, ulonglong#
Expand Down Expand Up @@ -96,6 +100,9 @@ npy_mul_with_overflow_size_t(size_t * r, size_t a, size_t b)
#endif
}

#ifdef __cplusplus
}
#endif

#endif

8 changes: 8 additions & 0 deletions numpy/_core/src/multiarray/_datetime.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
extern NPY_NO_EXPORT char const *_datetime_strings[NPY_DATETIME_NUMUNITS];
extern NPY_NO_EXPORT int _days_per_month_table[2][12];

#ifdef __cplusplus
extern "C" {
#endif

NPY_NO_EXPORT void
numpy_pydatetime_import(void);

Expand Down Expand Up @@ -334,4 +338,8 @@ datetime_hash(PyArray_DatetimeMetaData *meta, npy_datetime dt);
NPY_NO_EXPORT npy_hash_t
timedelta_hash(PyArray_DatetimeMetaData *meta, npy_timedelta td);

#ifdef __cplusplus
}
#endif

#endif /* NUMPY_CORE_SRC_MULTIARRAY__DATETIME_H_ */
8 changes: 8 additions & 0 deletions numpy/_core/src/multiarray/alloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#define NPY_TRACE_DOMAIN 389047
#define MEM_HANDLER_CAPSULE_NAME "mem_handler"

#ifdef __cplusplus
extern "C" {
#endif

NPY_NO_EXPORT PyObject *
_get_madvise_hugepage(PyObject *NPY_UNUSED(self), PyObject *NPY_UNUSED(args));

Expand Down Expand Up @@ -111,4 +115,8 @@ _npy_free_workspace(void *buf, void *static_buf)
#define npy_free_workspace(NAME) \
_npy_free_workspace(NAME, NAME##_static)

#ifdef __cplusplus
}
#endif

#endif /* NUMPY_CORE_SRC_MULTIARRAY_ALLOC_H_ */
7 changes: 7 additions & 0 deletions numpy/_core/src/multiarray/array_coercion.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#ifndef NUMPY_CORE_SRC_MULTIARRAY_ARRAY_COERCION_H_
#define NUMPY_CORE_SRC_MULTIARRAY_ARRAY_COERCION_H_

#ifdef __cplusplus
extern "C" {
#endif

/*
* We do not want to coerce arrays many times unless absolutely necessary.
Expand Down Expand Up @@ -58,4 +61,8 @@ npy_unlink_coercion_cache(coercion_cache_obj *current);
NPY_NO_EXPORT int
PyArray_AssignFromCache(PyArrayObject *self, coercion_cache_obj *cache);
< 10000 br>
#ifdef __cplusplus
}
#endif

#endif /* NUMPY_CORE_SRC_MULTIARRAY_ARRAY_COERCION_H_ */
8 changes: 8 additions & 0 deletions numpy/_core/src/multiarray/arraytypes.h.src
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

#include "common.h"

#ifdef __cplusplus
extern "C" {
#endif

NPY_NO_EXPORT int
set_typeinfo(PyObject *dict);

Expand Down Expand Up @@ -164,4 +168,8 @@ NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT int BOOL_argmax,
#undef INT_not_size_named
#undef LONGLONG_not_size_named

#ifdef __cplusplus
}
#endif

#endif /* NUMPY_CORE_SRC_MULTIARRAY_ARRAYTYPES_H_ */
7 changes: 7 additions & 0 deletions numpy/_core/src/multiarray/can_cast_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

#include "numpy/ndarraytypes.h"

#ifdef __cplusplus
extern "C" {
#endif

/* The from type fits into to (it has a smaller or equal number of bits) */
#define FITS(FROM, TO) (NPY_SIZEOF_##FROM <= NPY_SIZEOF_##TO)
Expand Down Expand Up @@ -121,4 +124,8 @@ static const npy_bool _npy_can_cast_safely_table[NPY_NTYPES_LEGACY][NPY_NTYPES_L
#undef CASTS_SAFELY_TO_FLOAT
#undef CASTS_SAFELY_TO_CFLOAT

#ifdef __cplusplus
}
#endif

#endif /* NUMPY_CORE_SRC_MULTIARRAY_CAN_CAST_TABLE_H_ */
8 changes: 8 additions & 0 deletions numpy/_core/src/multiarray/conversion_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

#include "numpy/ndarraytypes.h"

#ifdef __cplusplus
extern "C" {
#endif

NPY_NO_EXPORT int
PyArray_IntpConverter(PyObject *obj, PyArray_Dims *seq);

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

#ifdef __cplusplus
}
#endif

#endif /* NUMPY_CORE_SRC_MULTIARRAY_CONVERSION_UTILS_H_ */
Loading
Loading
0