You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[mypyc] Don't explicitly assign NULL values in setup functions (#15379)
While investigating something unrelated I stumbled across the `*_setup`
functions, and I noticed that they contain a lot of code that looks like
this:
```c
self->abc = NULL;
self->xyz = NULL;
// ...
```
Something told me that assigning `NULL` to a bunch of fields is propably
not needed, and when looking at the docs for `tp_alloc()` I found this
reference to
[`allocfunc`](https://docs.python.org/3/c-api/typeobj.html#c.allocfunc),
the typedef for `tp_alloc()`:
> It should return a pointer to a block of memory of adequate length for
the instance, suitably aligned, ***and initialized to zeros***, ...
Emphasis is mine.
Basically I added a simple check that removes lines that assigns `NULL`
values in setup functions. This removes about ~4100 lines from the C
file when self-compiling.
0 commit comments