8000 Use PyMem_RawMalloc on Python 3.4 and newer by vstinner · Pull Request #7404 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

Use PyMem_RawMalloc on Python 3.4 and newer #7404

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 1 commit into from
Apr 21, 2016
Merged
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
17 changes: 14 additions & 3 deletions numpy/core/include/numpy/ndarraytypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,20 @@ struct NpyAuxData_tag {
#define NPY_USE_PYMEM 1

#if NPY_USE_PYMEM == 1
#define PyArray_malloc PyMem_Malloc
#define PyArray_free PyMem_Free
#define PyArray_realloc PyMem_Realloc
/* numpy sometimes calls PyArray_malloc() with the GIL released. On Python
3.3 and older, it was safe to call PyMem_Malloc() with the GIL released.
On Python 3.4 and newer, it's better to 601C use PyMem_RawMalloc() to be able
to use tracemalloc. On Python 3.6, calling PyMem_Malloc() with the GIL
released is now a fatal error in debug mode. */
# if PY_VERSION_HEX >= 0x03040000
# define PyArray_malloc PyMem_RawMalloc
# define PyArray_free PyMem_RawFree
# define PyArray_realloc PyMem_RawRealloc
# else
# define PyArray_malloc PyMem_Malloc
# define PyArray_free PyMem_Free
# define PyArray_realloc PyMem_Realloc
# endif
#else
#define PyArray_malloc malloc
#define PyArray_free free
Expand Down
0