%a format

"Martin v. Löwis" martin at v.loewis.de
Wed Sep 8 14:18:39 EDT 2004


Skip Montanaro wrote:
>     >> Can you provide a patch against Objects/stringobject.c in the
>     >> distribution?  Note that Python uses sprintf() to do its dirty work,
>     >> so any patch would have to implement %a itself to remain compatible
>     >> with C89.
> 
>     John> is remaining compatible with C89 a requirement?
> 
> For the forseeable future I suspect so.  It was only a couple years ago that
> ANSI C became a requirement for building CPython.  Martin v. Löwis could
> provide a more authoritative response.

Indeed, we can't assume C99 for atleast 5 more years or so - for
example, VC.NET doesn't even implement it, even though that was
published 2003 (curiously, they cite "time constraints" as a reason :-);
whether they implement %a anyway, I don't know.

For the specific feature, I think a non-libc implementation would be
possible, since Python uses IEEE representation for floating point
numbers on most platforms (although atleast the VMS port doesn't
necessarily). Whether it is reasonable to implement this by mere
bit copying is a question that Tim Peters should answer :-)

Whatever the strategy, I think it should either work on all possible
systems, or on the majority and give an exception elsewhere.

Regards,
Martin




More information about the Python-list mailing list