-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
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
Add PyMem_Raw{New,Resize}
convenience macros
#127415
Comments
It seems to me that they wouldn't be worth it. |
Looking at the PR, I think the biggest difference would be that |
It isn't that much worse but it does use a different allocator function (one being calloc(), the other one being malloc()). In addition, IIRC, calloc() sets the memory to 0 while malloc() leaves area of memory uninitialized. For downstream users, I feel that it's better that they retain the semantics they want as well. |
I do see some usage, but Petr is less easily convinced. Generally for C API changes, you need to bicker with the C API WG first: https://github.com/capi-workgroup/decisions/issues |
Oh right. I'll move the discussion there (I tend to forget about the C API WG when the feature is small enough but I can try writing a more convincing proposal tomorrow) |
Having failed to convince the C API WG (and because I was less and less convinced as well), I will not push for this feature for now. |
Feature or enhancement
Proposal:
We have convenience macros for
PyMem_New
andPyMem_Resize
to allocate memory for n objects of the given type without checking ifn * sizeof(T)
would overflow but we don't have any for the raw allocators. I suggest adding those two macros.Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
Linked PRs
PyMem_Raw{New,Resize}
convenience macros #127416The text was updated successfully, but these errors were encountered: