Title: Unify `PyUncode_Count` and `unicode_count` · Issue #97982 · python/cpython · GitHub
Open Graph Title: Unify `PyUncode_Count` and `unicode_count` · Issue #97982 · python/cpython
X Title: Unify `PyUncode_Count` and `unicode_count` · Issue #97982 · python/cpython
Description: Feature or enhancement Right now PyUnicode_Count from cpython/Objects/unicodeobject.c Lines 8968 to 9040 in cbdeda8 Py_ssize_t PyUnicode_Count(PyObject *str, PyObject *substr, Py_ssize_t start, Py_ssize_t end) { Py_ssize_t result; int ki...
Open Graph Description: Feature or enhancement Right now PyUnicode_Count from cpython/Objects/unicodeobject.c Lines 8968 to 9040 in cbdeda8 Py_ssize_t PyUnicode_Count(PyObject *str, PyObject *substr, Py_ssize_t start, Py_...
X Description: Feature or enhancement Right now PyUnicode_Count from cpython/Objects/unicodeobject.c Lines 8968 to 9040 in cbdeda8 Py_ssize_t PyUnicode_Count(PyObject *str, PyObject *substr, Py_ssize_t start, Py_...
Opengraph URL: https://github.com/python/cpython/issues/97982
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Unify `PyUncode_Count` and `unicode_count`","articleBody":"# Feature or enhancement\r\n\r\nRight now `PyUnicode_Count` from https://github.com/python/cpython/blob/cbdeda8ce7a3543cb3376d70e4cd46fcf24f42a7/Objects/unicodeobject.c#L8968-L9040 and `unicode_count` from https://github.com/python/cpython/blob/cbdeda8ce7a3543cb3376d70e4cd46fcf24f42a7/Objects/unicodeobject.c#L10854-L10916 share a lot of code.\r\n\r\nThey can be unified, because the do the same thing.\r\n\r\n# Pitch\r\n\r\n[Citing](https://github.com/python/cpython/pull/96929#issuecomment-1270262538) @encukou:\r\n\r\n\u003e Apparently unicode_count missed [an optimization in 2011](https://github.com/python/cpython/commit/c3cec7868bf1019c0987f1e9aadb56d73fa93d61), otherwise they're equivalent (except arg parsing \u0026 converting the return value). Merging them could add the optimization to unicode_count.\r\nIf you want to work on that, note that there's also anylib_count that duplicates the main switch.\r\n\r\n# Previous discussion\r\n\r\n\u003c!--\r\n New features to Python should first be discussed elsewhere before creating issues on GitHub,\r\n for example in the \"ideas\" category (https://discuss.python.org/c/ideas/6) of discuss.python.org,\r\n or the python-ideas mailing list (https://mail.python.org/mailman3/lists/python-ideas.python.org/).\r\n Use this space to post links to the places where you have already discussed this feature proposal:\r\n--\u003e\r\n\r\nLink: https://github.com/python/cpython/pull/96929\r\n\r\n\u003c!--\r\nYou can freely edit this text. Remove any lines you believe are unnecessary.\r\n--\u003e\r\n\r\nPR in the works.","author":{"url":"https://github.com/sobolevn","@type":"Person","name":"sobolevn"},"datePublished":"2022-10-06T18:06:05.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/97982/cpython/issues/97982"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:6f77b1b3-2572-1ae1-f630-bc9812c860bd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B6EE:2D4000:196907B:2365EF4:696A4EDA |
| html-safe-nonce | c35f2f4ea63f0a4287a0c263c9b63e1af15bfb728aa796b41533c4db5aeac51c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNkVFOjJENDAwMDoxOTY5MDdCOjIzNjVFRjQ6Njk2QTRFREEiLCJ2aXNpdG9yX2lkIjoiNDE4MDc1ODE0MzA2ODQyNTk0NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 861b54c3c733937e97bb0153bd7359d236b7e05e0b11eb1a7bfccaac2880ac3b |
| hovercard-subject-tag | issue:1400099347 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/97982/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1791612c710ddc6aa8c808038c95129d6be75c7c57e71fb83de2dbeda705a364/python/cpython/issues/97982 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1791612c710ddc6aa8c808038c95129d6be75c7c57e71fb83de2dbeda705a364/python/cpython/issues/97982 |
| og:image:alt | Feature or enhancement Right now PyUnicode_Count from cpython/Objects/unicodeobject.c Lines 8968 to 9040 in cbdeda8 Py_ssize_t PyUnicode_Count(PyObject *str, PyObject *substr, Py_ssize_t start, Py_... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sobolevn |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3f871c8e07f0ae1886fa8dac284166d28b09ad5bada6476fc10b674e489788ef |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 63c426b30d262aba269ef14c40e3c817b384cd61 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width