Skip to content
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

[mypyc] Don't explicitly assign NULL values in setup functions #15379

Merged
merged 1 commit into from
Jun 12, 2023

Commits on Jun 6, 2023

  1. Don't explicitly assign NULL values in setup functions:

    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 similar to above which
    assigns `NULL` values in setup functions. This removes about ~4100 lines from
    the C file when self-compiling.
    dosisod committed Jun 6, 2023
    Configuration menu
    Copy the full SHA
    2fbf709 View commit details
    Browse the repository at this point in the history