The C standard defines the locale as a program-wide property
that may be relatively expensive to change. On top of that, some
implementation are broken in such a way that frequent locale
changes may cause core dumps. This makes the locale somewhat
painful to use correctly. Initially, when a program is started,
the locale is the "C" locale, no matter what the user's
preferred locale is. The program must explicitly say that it
wants the user's preferred locale settings by It is generally a
bad idea to call setlocale() in some library routine, since as a
side effect it affects the entire program. Saving and restoring
it is almost as bad: it is expensive and affects other threads
that happen to run before the settings have been restored. If,
when coding a module for general use, you need a locale
independent version of an operation that is affected by the
locale (such as string.lower(), or certain formats used with
time.strftime()), you will have to find a way to do it without
using the standard library routine.