Match beginning of two strings

Christos TZOTZIOY Georgiou tzot at sil-tec.gr
Wed Aug 6 20:54:17 CEST 2003


On Sat, 02 Aug 2003 17:39:26 -0400, rumours say that Ravi
<rxs141 at cwru.edu> might have written:

>I have about 200GB of data that I need to go through and extract the 
>common first part of a line. Something like this.

If you know in advance that many of these comparisons will involve large
strings, you might improve your apps' response time by using the
os.path.commonprefix function modified as proposed in

http://sourceforge.net/tracker/index.php?func=detail&aid=681780&group_id=5470&atid=305470

which is O(logN)-ish instead of O(N).  This patch was sent by me, but
there is a suggestion by another SF user which seems to be efficient too
(never benchmarked it against mine).
-- 
TZOTZIOY, I speak England very best,
Microsoft Security Alert: the Matrix began as open source.




More information about the Python-list mailing list