Skip to content

Use _PyLong_GetOne() and _PyLong_GetZero() in Objects #125442

Closed as not planned
Closed as not planned
@hikariyo

Description

@hikariyo

Feature or enhancement

Proposal:

There are several statements in longobject.c that still uses PyLong_FromLong(0L) and PyLong_FromLong(1L).

cpython/Objects/longobject.c

Lines 5006 to 5008 in 67f6e08

z = (PyLongObject *)PyLong_FromLong(1L);
if (z == NULL)
goto Error;

return PyLong_FromLong(0);

And so on.

Use _PyLong_GetOne() and _PyLong_GetZero() can reduce null check and might reduce minor memory usage, as they use static caches.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions