8000 WIP, MAINT: simplify generic type memory handling by tylerjereddy · Pull Request #11836 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

WIP, MAINT: simplify generic type memory handling #11836

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

Conversation

tylerjereddy
Copy link
Contributor
@tylerjereddy tylerjereddy commented Aug 29, 2018

I was experimenting with various permutations of the memory handling used by the generic type arrays. There's a comment in the source suggesting that we may not necessarily need to zero allocated memory before initializing the type data into it.

I figured this might be a bad idea since "residual" data in that memory block might cause all kinds of mysterious behaviors with things that are "supposed to be 0" actually being something else because of whatever was there before, etc.

However, I only see one unit test failure in the --mode=full test suite after making the change, test_pickle_empty_string, which produces a bizarre failure where b' ' != b' '; perhaps related to #5475. The test failure report is not informative at all -- it shows two identical-looking objects as being unequal, but maybe there's a subtle null-termination or related issue because of the non-zeroing.

I can also get the full suite to pass if I switch to PyObject_Calloc to auto-zero the memory block and then we can just use (void) PyObject_InitVar((PyVarObject *)obj, type, nitems); and not worry about fixed-width vs. variable width types because the tp_itemsize is used in a memory-related product downstream and should be 0 for fixed case. Although the full suite passes, I think the Python C API for that is 3.5 +.

Edit: see Python 3.6 --full test suite job for single failure; Python 2.7 is another matter

* generic type array memory initialization
has been simplified to use PyObject_NewVar
without zeroing the memory block
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0