Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 65a3332

Browse files
committed
Add PEP 331; add constancy of None; minor edits
1 parent c2632a5 commit 65a3332

1 file changed

Lines changed: 45 additions & 5 deletions

File tree

Doc/whatsnew/whatsnew24.tex

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
\documentclass{howto}
32
\usepackage{distutils}
43
% $Id$
@@ -443,6 +442,44 @@ \subsection{The \class{Context} type}
443442
\end{seealso}
444443

445444

445+
%======================================================================
446+
\section{PEP 331: Locale-Independent Float/String Conversions}
447+
448+
The \module{locale} modules lets Python software select various
449+
conversions and display conventions that are localized to a particular
450+
country or language. However, the module was careful to not change
451+
the numeric locale because various functions in Python's
452+
implementation required that the numeric locale remain set to the
453+
\code{'C'} locale. Often this was because the code was using the C library's
454+
\cfunction{atof()} function.
455+
456+
Not setting the numeric locale caused trouble for extensions that used
457+
third-party C libraries, however, because they wouldn't have the
458+
correct locale set. The motivating example was GTK+, whose user
459+
interface widgets weren't displaying numbers in the current locale.
460+
461+
The solution described in the PEP is to add three new functions to the
462+
Python API that perform ASCII-only conversions, ignoring the locale
463+
setting:
464+
465+
\begin{itemize}
466+
\item \cfunction{PyOS_ascii_strtod(\var{str}, \var{ptr})}
467+
and \cfunction{PyOS_ascii_atof(\var{str}, \var{ptr})}
468+
both convert a string to a C \ctype{double}.
469+
\item \cfunction{PyOS_ascii_formatd(\var{buffer}, \var{buf_len}, \var{format}, \var{d})} converts a \ctype{double} to an ASCII string.
470+
\end{itemize}
471+
472+
The code for these functions came from the GLib library
473+
(\url{http://developer.gnome.org/arch/gtk/glib.html}), whose
474+
developers kindly relicensed the relevant functions and donated them
475+
to the Python Software Foundation. The \module{locale} module
476+
can now change the numeric locale, letting extensions such as GTK+
477+
produce the correct results.
478+
479+
\begin{seealso}
480+
\seepep{331}{Locale-Independent Float/String Conversions}{Written by Christian R. Reis, and implemented by Gustavo Carneiro.}
481+
\end{seealso}
482+
446483
%======================================================================
447484
\section{Other Language Changes}
448485

@@ -578,6 +615,9 @@ \section{Other Language Changes}
578615
[]
579616
\end{verbatim}
580617

618+
\item \constant{None} is now a constant; code that binds a new value to
619+
the name \samp{None} is now a syntax error.
620+
581621
\end{itemize}
582622

583623

@@ -587,10 +627,10 @@ \subsection{Optimizations}
587627
\begin{itemize}
588628

589629
\item The inner loops for list and tuple slicing
590-
were optimized and now run about one-third faster. The inner
591-
loops were also optimized for dictionaries with performance
592-
boosts to \method{keys()}, \method{values()}, \method{items()},
593-
\method{iterkeys()}, \method{itervalues()}, and \method{iteritems()}.
630+
were optimized and now run about one-third faster. The inner loops
631+
were also optimized for dictionaries, resulting in performance boosts for
632+
\method{keys()}, \method{values()}, \method{items()},
633+
\method{iterkeys()}, \method{itervalues()}, and \method{iteritems()}.
594634

595635
\item The machinery for growing and shrinking lists was optimized for
596636
speed and for space efficiency. Appending and popping from lists now

0 commit comments

Comments
 (0)