[Python-ideas] Format mini-language for lakh and crore

Steve Dower steve.dower at python.org
Mon Jan 29 05:54:44 EST 2018


Someone would have to check, but presumably the CRT on Windows is converting the natively thread-local locale into a process-wide locale for POSIX compatibility, which means it can probably be easily bypassed without having to use specific overloads.

Top-posted from my Windows phone

From: Nathaniel Smith
Sent: Monday, January 29, 2018 11:29
To: Eric V. Smith
Cc: python-ideas
Subject: Re: [Python-ideas] Format mini-language for lakh and crore

On Sun, Jan 28, 2018 at 5:46 AM, Eric V. Smith <eric at trueblade.com> wrote:
> If I recall correctly, we discussed this at the time, and the problem with
> locale is that it's not thread safe. I agree that if it were, it would be
> nice to be able to use it, either with 'n', or in some other mode just for
> grouping.
>
> The underlying C setlocale()/localeconv() just isn't very friendly to this
> use case.

POSIX.1-2008 added thread-local locales (say that 3x fast); see
uselocale(3). This appears to be supported on Linux (since glibc 2.3,
which is older than all supported enterprise distros), MacOS, and the
BSDs, but not Windows. OTOH Windows, MacOS, and the BSDs all seem to
provide the non-standard sprintf_l, which takes an explicit locale to
use.

So it looks like all mainstream OSes actually make it possible to use
a specific locale to do arbitrary formatting in a thread-safe way.

-n

-- 
Nathaniel J. Smith -- https://vorpus.org
_______________________________________________
Python-ideas mailing list
Python-ideas at python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180129/7aae5641/attachment.html>


More information about the Python-ideas mailing list