duplication of logic

P at draigBrady.com P at draigBrady.com
Tue Nov 4 06:32:04 EST 2003


John Roth wrote:
> "George Trojan" <george.trojan at noaa.gov> wrote in message
> news:bo6oaf$vfq$1 at news.nems.noaa.gov...
> 
>>Is time.strptime() intrinsically slow and should be avoided whenever
>>possible? I have the following code in my application:
> 
> 
> According to the "what's new in Python" for 2.3, the strptime
> implementation was switched from a lightweight wrapper
> around the frequently buggy and incompatible C library
> to a portable pure Python implementation.
> 
> Yes, it's going to be a lot slower.

This duplication of logic looks like a trend?

For e.g. locale.format is very simplistic (in 2.2.2 at least)
It groups %s items as numbers:
     locale.format("%s",1234,1) -> '1,234'
and treats non numbers as numbers:
      locale.format("%s\n",1234,1) -> '12,34\n'
This should be fixed, or changed to just taking an
int and returning a string or better using the
glibc facility of the ' modifier. e.g "%'d"
This applies to any decimal conversion (i,d,u,f,F,g,G)
You wouldn't have to use it directly, just in locale.format()
you could add in a ' in the appropriate places.
Note this is SUSV2 not just glibc
 

Another e.g. where glibc functionality should be used rather than
reimplementing in python is the parsing of mo files.
Note Solaris mo files are not supported currently anyway.

I know python has to be cross platform, but automatically setting
things up to use the system libraries where appropriate would
be a benefit to performance and functionality IMHO.

Pádraig.





More information about the Python-list mailing list