[Patches] [ python-Patches-681780 ] Faster commonprefix (OS independent)

SourceForge.net noreply@sourceforge.net
Thu, 06 Feb 2003 09:04:42 -0800


Patches item #681780, was opened at 2003-02-06 19:03
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=681780&group_id=5470

Category: Library (Lib)
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Christos Georgiou (tzot)
Assigned to: Nobody/Anonymous (nobody)
Summary: Faster commonprefix (OS independent)

Initial Comment:
This routine is about 20% faster on a test set of 7 sets 
of strings run 100000 times each (I can provide the test 
if requested).  The longer the common prefix is, the 
faster the routine becomes relative to original 
commonprefix.

My only worry is that it might get rejected if it is 
considered too fancy; therefore I wasn't shy on 
commenting.

I think we should also write a commonpathprefix, that 
will do what commonprefix should do, being in the 
*path.py module.  I'll do that if none other does.

The provided patch is for posixpath.py and ntpath.py, 
but since it's OS neutral it should work as is.  It uses 
itertools for speed, though, so it is not backportable, but 
it can be if requested by substituting map for imap and a 
normal slice for islice.

----------------------------------------------------------------------

>Comment By: Christos Georgiou (tzot)
Date: 2003-02-06 19:04

Message:
Logged In: YES 
user_id=539787

For some reason, my IE never uploads the file on the first 
attempt.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=681780&group_id=5470