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
Remove unicode_format.h from stringlib #69127
Comments
Objects/stringlib/unicode_format.h does not belong in stringlib. Back when it was originally written for 2.x, it used stringlib to provide the str and unicode versions of str.format, str.__format__, int.__format__, etc. However, in 3.x, and especially with PEP-393 (Flexible String Representation), not only is the stringlib functionality no longer needed, it's not used at all. My suggestion is to just copy the source into Objects/unicodeobject.c, which is the only place it's used. Then delete the stringlib file. The only downside of including it in unicodeobject.c is that it makes our largest C file about 8% larger: wc -l says: There's some argument to be made to separate out the int.__format__, float.__format__ etc. code, and move them to some other library. I don't think they're a huge part of unicode_format.h. And to separate them out would require creating some _Py_* functions to do their work. But it's probably the right thing to do. I'll investigate. |
Actually, int.__format__, etc. are not in this file. So that's good. The things that are in this file but are unrelated to unicodeobject.c are the support routines for implementing string.Formatter. I think I'll move those elsewhere, as a first step. |
Eric, there have been further changes to Objects/stringlib/unicode_format.h since this original note, I've raised a PR with the intent of your note from 2015. There also hasn't been any change to the situation, unicode_format.h is only used in unicodeobject.c stil. |
I'm not sure which functions that relates to, if you could let me know I'd be happy to add those to the PR. |
I think I meant things like PyFieldNameIter_Type, but it would require some analysis. |
The code is mostly: FieldNameIterator * related functions There are a few other utility methods in there as well |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: