PEP 378: Format Specifier for Thousands Separator
Carlos Nepomuceno
carlosnepomuceno at outlook.com
Wed May 22 20:44:36 EDT 2013
----------------------------------------
> From: oscar.j.benjamin at gmail.com
> Date: Thu, 23 May 2013 01:30:53 +0100
> Subject: Re: PEP 378: Format Specifier for Thousands Separator
> To: carlosnepomuceno at outlook.com
> CC: pruebauno at latinmail.com; python-list at python.org
>
> On 22 May 2013 23:31, Carlos Nepomuceno <carlosnepomuceno at outlook.com> wrote:
>>
>> I still don't understand why % benefits from literals optimization ("'%d'%12345") while '{:d}'.format(12345) doesn't.
>
> There's no reason why that optimisation can't happen in principle.
> However no one has written a patch for it. Why don't you look into
> what it would take to make it happen?
>
>
> Oscar
Maybe I'll look into that later, but I couldn't even find how the hell they made _Py_InsertThousandsGrouping() been called.
That's what I got when analysing % formating:
Thousands separator format specifier for str.__mod__()
======================================================
@Objects/stringobject.c: implements formatint() for '%' processing
-Looking for code used in str.format()
@Objects/stringlib/formatter.h: implements str.format()
-It uses STRINGLIB_GROUPING() to do the job.
@Objects/stringlib/stringdefs.h: #define STRINGLIB_GROUPING _PyString_InsertThousandsGrouping
@Objects/stringlib/unicodedefs.h: #define STRINGLIB_GROUPING _PyUnicode_InsertThousandsGrouping
@Objects/stringobject.c: #define _Py_InsertThousandsGrouping _PyString_InsertThousandsGrouping
@Objects/stringobject.h: declares _PyString_InsertThousandsGrouping()
@???: ??? _PyString_InsertThousandsGrouping ??? _Py_InsertThousandsGrouping
@Objects/stringlib/localeutil.h: implements _Py_InsertThousandsGrouping()
Let me explain what that means. I found no relating declarations/definitions that turn _PyString_InsertThousandsGrouping into _Py_InsertThousandsGrouping.
So, I don't even know how that source code compiles without error.
:/ really strange...
Not to mention the lots of code inside header definition files! Weird!!!!
More information about the Python-list
mailing list