Skip to content

Conversation

@kumaraditya303
Copy link
Contributor

@kumaraditya303 kumaraditya303 commented Jan 22, 2022

By using global singletons for single byte bytes objects in deepfreeze, there is no need to generate c code for it so it reduces the size of generated c file and reduces memory use of the objects when they are allocated on the heap as now they are statically allocated and they are already immortal.

https://bugs.python.org/issue46471

Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How many of these do you see in deepfreeze.c? Singletons byte literals aren’t that common I guess.

@kumaraditya303
Copy link
Contributor Author

How many of these do you see in deepfreeze.c? Singletons byte literals aren’t that common I guess.

cat Python/deepfreeze/deepfreeze.c | grep "(PyObject \*)&_Py_SINGLETON(bytes_characters" | wc -l
200

Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see. co_localspluskinds is a bytes object (flags for args and local vars) and when there's exactly one of those, it qualifies. Clever.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants