GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-66802: Add `unicodedata.block()` function by StanFromIreland · Pull Request #145042 · python/cpython

Conversation

@StanFromIreland

@StanFromIreland StanFromIreland commented Feb 20, 2026 •
edited by github-actions Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member
  • Issue: Add block info to unicodedata #66802

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@StanFromIreland
Implement unicodedata.block()
a4421f5
@StanFromIreland
StanFromIreland requested review from ezio-melotti, malemburg and serhiy-storchaka February 20, 2026 16:11
@StanFromIreland
StanFromIreland requested a review from AA-Turner as a code owner February 20, 2026 16:11
@bedevere-app bedevere-app Bot added the awaiting review label Feb 20, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Feb 20, 2026
Add block info to unicodedata #66802
Closed
@StanFromIreland
Remove helper
e80bac4
ezio-melotti
ezio-melotti reviewed Feb 20, 2026
View reviewed changes
Comment thread Lib/test/test_unicodedata.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Modules/unicodedata.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Modules/unicodedata.c
[clinic start generated code]*/

static PyObject *
unicodedata_block_impl(PyObject *module, int chr)

@ezio-melotti ezio-melotti Feb 20, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Have you tried other approaches for this, and compared the performances?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@StanFromIreland StanFromIreland Feb 21, 2026

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Table with ranges & bin search (PR) Adding to each record
unique properties 395 1829
size of unicodedata_db.h (bytes) 626,364 759,474
simple bench* 498 nsec per loop 490 nsec per loop

* ./python -m timeit -v -r 10 -n 1000000 -s "import unicodedata; b=unicodedata.block" "b('\u0041');b('\u4E00');b('\U0010FFFF')"

The lookup difference is minor, and we save quite a bit of memory (~17%), so I think this approach is better.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Tools/unicode/makeunicodedata.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Tools/unicode/makeunicodedata.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

StanFromIreland and others added 2 commits February 21, 2026 09:58
@StanFromIreland @ezio-melotti
Update Modules/unicodedata.c
76f7538
Co-authored-by: Ezio Melotti <[email protected]>
@StanFromIreland
Ezio's review
1cfc852
vstinner
vstinner reviewed Feb 21, 2026
View reviewed changes
Comment thread Doc/library/unicodedata.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Tools/unicode/makeunicodedata.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Modules/unicodedata.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Tools/unicode/makeunicodedata.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_unicodedata.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@StanFromIreland
Stop being lazy
e108e27
@StanFromIreland
StanFromIreland requested review from ezio-melotti and vstinner February 21, 2026 11:10
vstinner
vstinner approved these changes Feb 21, 2026
View reviewed changes

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM. The implementation with a binary tree is efficient (CPU, memory). It's a reasonable addition to the unicodedata module.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels Feb 21, 2026
malemburg
malemburg approved these changes Feb 21, 2026
View reviewed changes

@malemburg malemburg left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM, but please do check whether using size_t for namelen wouldn't be better.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Modules/unicodedata.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

@malemburg
malemburg merged commit f1f61bf into python:main Feb 21, 2026
51 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting merge label Feb 21, 2026
@malemburg

malemburg commented Feb 21, 2026

Copy link
Copy Markdown
Member

Thanks, @StanFromIreland

StanFromIreland reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@StanFromIreland
StanFromIreland deleted the unicodedata-blocks branch February 21, 2026 17:35
brijkapadia pushed a commit to brijkapadia/cpython that referenced this pull request Feb 28, 2026
@StanFromIreland @brijkapadia
pythongh-66802: Add unicodedata.block() function (python#145042)
7938d2f
Closes python#66802
ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
@StanFromIreland @ljfp
pythongh-66802: Add unicodedata.block() function (python#145042)
c302174
Closes python#66802
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@vstinner vstinner vstinner approved these changes
@malemburg malemburg malemburg approved these changes
@serhiy-storchaka serhiy-storchaka Awaiting requested review from serhiy-storchaka
@AA-Turner AA-Turner Awaiting requested review from AA-Turner AA-Turner is a code owner
@ezio-melotti ezio-melotti Awaiting requested review from ezio-melotti

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@StanFromIreland @malemburg @vstinner @ezio-melotti
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.