GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||
GeezerVison is showing github.com — gh-66802: Add `unicodedata.block()` function by StanFromIreland · Pull Request #145042 · python/cpython Conversation
|
| [clinic start generated code]*/ | ||
|
|
||
| static PyObject * | ||
| unicodedata_block_impl(PyObject *module, int chr) |
There was a problem 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.
There was an error while loading. Please reload this page.
There was a problem 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.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Co-authored-by: Ezio Melotti <[email protected]>
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem 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.
There was an error while loading. Please reload this page.
There was a problem 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.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Thanks, @StanFromIreland |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.