Commit 9b9272a
authored
[mypyc] Don't explicitly assign
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.NULL values in setup functions (#15379)1 parent 4aa18ea commit 9b9272a
1 file changed
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
578 | 578 | | |
579 | 579 | | |
580 | 580 | | |
581 | | - | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
582 | 587 | | |
583 | 588 | | |
584 | 589 | | |
| |||
0 commit comments