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

bpo-46881: Statically allocate and initialize the latin1 characters. #31616

Merged
merged 8 commits into from Mar 9, 2022

Conversation

kumaraditya303
Copy link
Contributor

@kumaraditya303 kumaraditya303 commented Feb 28, 2022

https://bugs.python.org/issue46881

Automerge-Triggered-By: GH:ericsnowcurrently

Copy link
Member

@ericsnowcurrently ericsnowcurrently left a comment

Choose a reason for hiding this comment

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

Other than one small thing, LGTM.

Objects/unicodeobject.c Outdated Show resolved Hide resolved
@kumaraditya303
Copy link
Contributor Author

This will require some more changes because only strings in range(128) use PyASCIIObject whereas latin1 uses PyCompactUnicodeObject hence tests are failing.
One idea I have is to use have two array of struct one of PyASCIIObject and one PyCompactUnicodeObject to store the latin1 characters.

@ericsnowcurrently
Copy link
Member

You might want to take a look at my attempt at this from December: ericsnowcurrently@9c93a13. Its a little outdated but, IIRC, it worked.

@ericsnowcurrently
Copy link
Member

Also, we should probably add all 256 to _PyRuntimeState.global_objects.singletons.strings, identifiers for the ASCII alphabet characters and literals for the rest. Then we point to those in our lookup array.

@kumaraditya303 kumaraditya303 marked this pull request as ready for review March 3, 2022 11:25
Copy link
Member

@ericsnowcurrently ericsnowcurrently left a comment

Choose a reason for hiding this comment

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

This is looking good. I've left a couple comments for you to consider.

Also, I recommend updating _PyUnicode_InitGlobalObjects() to call _PyUnicode_CheckConsistency() on each of the latin1 objects, like we do with the empty string. This helps ensure that we are statically initializing the objects correctly. We should probably do that for at least one of the identifiers and one of the other "literals", for the same reason, but that can be addressed separately.

Objects/unicodeobject.c Outdated Show resolved Hide resolved
Include/internal/pycore_runtime_init.h Outdated Show resolved Hide resolved
@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@ericsnowcurrently
Copy link
Member

ericsnowcurrently commented Mar 3, 2022

Please avoid rebasing once someone has reviewed a PR. It makes it hard for others to follow what you have changed (and GitHub isn't great at adjusting for the "force push"). Instead, merge main into your branch.

@kumaraditya303
Copy link
Contributor Author

Please avoid rebasing once someone has reviewed a PR. It makes it hard for others to follow what you have changed (and GitHub isn't great at adjusting for the "force push"). Instead, merge main into your branch.

Yes, I try to avoid rebase but there was a conflict and I basically had to rewrite the PR so rebase and start from main branch was easier.

@ericsnowcurrently
Copy link
Member

there was a conflict and I basically had to rewrite the PR so rebase and start from main branch was easier.

I've certainly been in that situation. 🙂 The problem here is that I could not tell what you changed since the last time I looked at the PR. Also, GitHub doesn't show the results of previous CI runs if you force-push. I wanted to see what was failing there before. Neither would have been a problem with a merge instead of a rebase.

It's not the end of the world but it does relate to the community nature of Python core development. In case you find it helpful, here's a little insight:

The question of rebase-vs-merge in a PR is one of those little things that can add up in an open-source project's collaborative workflow. My concern isn't so much for my own time (though I do appreciate consideration 🙂). Rather, I strongly encourage you to be respectful of reviewers' time in general. In a community project like CPython, we all need to treat the time of other contributors as sacred. I always try to ask myself if there's good reason to (effectively) demand that someone else spend an additional portion of their free time to accommodate me saving some time. The answer is almost always "no".

My intention isn't to chastise you or tell you that you are doing anything wrong. I just want to be sure you have an awareness of the human element of the project. I really do appreciate all the work you have been doing on behalf of the Python community! Python wouldn't be nearly as great as it is without contributors like you sacrificing their spare time. ❤️

@kumaraditya303
Copy link
Contributor Author

I have made the requested changes; please review again

@bedevere-bot
Copy link

Thanks for making the requested changes!

@ericsnowcurrently: please review the changes made to this pull request.

Copy link
Member

@ericsnowcurrently ericsnowcurrently left a comment

Choose a reason for hiding this comment

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

LGTM )aside from a couple of minor comments)

I'll merge once the remaining review comments are addressed.

Include/internal/pycore_runtime_init.h Outdated Show resolved Hide resolved
Include/internal/pycore_runtime_init.h Outdated Show resolved Hide resolved
@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@kumaraditya303
Copy link
Contributor Author

I have made the requested changes; please review again

@bedevere-bot
Copy link

Thanks for making the requested changes!

@ericsnowcurrently: please review the changes made to this pull request.

@kumaraditya303
Copy link
Contributor Author

@ericsnowcurrently FYI I had changed the macros as you suggested, please review again thanks

Copy link
Member

@ericsnowcurrently ericsnowcurrently left a comment

Choose a reason for hiding this comment

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

LGTM

Thanks for working on this!

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.

None yet

5 participants