[Python-Dev] Deprecating PyOS_ascii_formatd

Eric Smith eric at trueblade.com
Thu Apr 9 01:07:45 CEST 2009

Assuming that Mark's and my changes in the py3k-short-float-repr branch 
get checked in shortly, I'd like to deprecate PyOS_ascii_formatd. Its 
functionality is largely being replaced by PyOS_double_to_string, which 
we're introducing on our branch.

PyOS_ascii_formatd was introduced to fix the issue in PEP 331. 
PyOS_double_to_string addresses all of the same issues, namely a 
non-locale aware double-to-string conversion. PyOS_ascii_formatd has an 
unfortunate interface. It accepts a printf-like format string for a 
single double parameter. It must parse the format string into the 
parameters it uses. All uses of it inside Python already know the 
parameters and must build up a format string using sprintf, only to turn 
around and have PyOS_ascii_formatd reparse it.

In the branch I've replaced all of the internal calls to 
PyOS_ascii_format with PyOS_double_to_string.

My proposal is to deprecate PyOS_ascii_formatd in 3.1 and remove it in 3.2.

The 2.7 situation is tricker, because we're not planning on backporting 
the short-float-repr work back to 2.7. In 2.7 I guess we'll leave 
PyOS_ascii_formatd around, unfortunately.

FWIW, I didn't find any external callers of it using Google code search.

And as a reminder, the py3k-short-float-repr changes are on Rietveld at 
http://codereview.appspot.com/33084/show. So far, no comments.

More information about the Python-Dev mailing list