Some optimization tale

Christos TZOTZIOY Georgiou tzot at sil-tec.gr
Tue Dec 30 13:30:50 CET 2003


On Mon, 29 Dec 2003 17:08:39 +0100, rumours say that Stephan Diehl
<stephan.diehlNOSPAM at gmx.net> might have written:

>> You might also want to read:
>> 
>> http://www.python.org/sf/681780
>
>Terry's solution is much faster (at least on my test set) and, as an
>additional benefit, is the easiest to understand.

Yep, I believe clarity is essential in the library (and that is why my
patch was obviously not accepted :)  Actually IIRC (it's been a long
since) that code never compares more than once prefixes that have been
found equal and does not create slices (used buffer() and then switched
to startswith() for future compatibility), that is why it's a little
complicated.  The main loop runs math.ceil(math.log(N,2)) times, where N
is min([len(x) for x in argument_list]).

Anyway, perhaps Terry or you should update the SF patch so that
os.path.commonprefix becomes faster... the point is to benefit the whole
Python community, right? :)
-- 
TZOTZIOY, I speak England very best,
Ils sont fous ces Redmontains! --Harddix




More information about the Python-list mailing list