Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-76535: MakePyUnicode_ToLowerFull and friends public#136176

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
lysnikolaou wants to merge12 commits intopython:main
base:main
Choose a base branch
Loading
fromlysnikolaou:pyunicode-tolower-public

Conversation

lysnikolaou
Copy link
Member

@lysnikolaoulysnikolaou commentedJul 1, 2025
edited
Loading

Make_PyUnicode_ToLowerFull,_PyUnicode_ToUpperFull,_PyUnicode_ToTitleFull and_PyUnicode_ToFoldedFull public and rename them toPyUnicode_ToLower etc.


📚 Documentation preview 📚:https://cpython-previews--136176.org.readthedocs.build/

Make `PyUnicode_ToLowerFull`, `PyUnicode_ToUpperFull` and`PyUnicode_ToTitleFull` public and rename them to `PyUnicode_ToLower`etc.
@lysnikolaou
Copy link
MemberAuthor

Thanks for taking a look@vstinner! Feedback addressed.

Copy link
Member

@serhiy-storchakaserhiy-storchaka left a comment

Choose a reason for hiding this comment

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

In#76535 (comment)@vstinner suggested to provide a constant which is the minimum buffer size.

If this is indeed a hard constant which will never be changed in future Unicode standards, then I prefer this way. It is too expensive to allocate the output buffer dynamically.

cc@ezio-melotti, our Unicode expert.

@lysnikolaou
Copy link
MemberAuthor

Another question I have is whether we want to expose something like the following to handle the Greek letter sigma edge case:

intPyUnicode_ToLowerHandleSigma(Py_UCS4*str,Py_UCS4ch,Py_UCS4*buffer,intsize)

Copy link
Member

@vstinnervstinner left a comment

Choose a reason for hiding this comment

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

Thanks, I prefer this API which is more future-proof, it doesn't depend on a specific Unicode version.

@vstinner
Copy link
Member

PyUnicode_ToLowerHandleSigma

Would you mind to elaborate? I'm not aware of this special case.

@vstinner
Copy link
Member

If this is indeed a hard constant which will never be changed in future Unicode standards

Even if it's a constant which will never (!) change, IMO it's better to request a size as an argument to make the caller responsible to check the buffer size. APIs which accept a pointer with no size are a bad pattern, like the deprecated gets() function.

@lysnikolaou
Copy link
MemberAuthor

Further feedback addressed.

Would you mind to elaborate? I'm not aware of this special case.

There's one special case, the Greek letter sigma, where the result of lower casing is context-specific. More specifically,Σ gets lower-cased toς if it's at the end of the word or toσ otherwise. This is handled inlower_ucs4 right now.

Copy link
Member

@vstinnervstinner left a comment

Choose a reason for hiding this comment

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

Can you try to add tests toModules/_testcapi/unicode.c andLib/test/test_capi/test_unicode.py?

@vstinner
Copy link
Member

There's one special case, the Greek letter sigma, where the result of lower casing is context-specific. More specifically, Σ gets lower-cased to ς if it's at the end of the word or to σ otherwise.

Oh, that's a tricky case. Proposed API takes a single character, so we don't know if Σ is at the end of a word or not. I don't think that it's worth it to handle this special case in proposed API.

lysnikolaou reacted with thumbs up emoji

@lysnikolaou
Copy link
MemberAuthor

Can you try to add tests toModules/_testcapi/unicode.c andLib/test/test_capi/test_unicode.py?

Done.

@serhiy-storchaka
Copy link
Member

If we add too many parameters and runtime checks, this will make the API slower and more difficult to use.

Copy link
Member

@vstinnervstinner left a comment

Choose a reason for hiding this comment

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

LGTM, I just have some minor comments.

@serhiy-storchaka: Would you be ok with this approach? An API with asize parameter.

@lysnikolaou
Copy link
MemberAuthor

All feedback addressed! Thanks for all the help and patience@vstinner!

vstinner reacted with heart emoji

@lysnikolaou
Copy link
MemberAuthor

Friendly ping.

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

@vstinnervstinnervstinner approved these changes

@serhiy-storchakaserhiy-storchakaserhiy-storchaka left review comments

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@lysnikolaou@vstinner@serhiy-storchaka

[8]ページ先頭

©2009-2025 Movatter.jp