Hugh Gibson wrote:
> Thomas, I saw your change for the python tool routine to get common
> prefixes of a string at
> http://qooxdoo.svn.sourceforge.net/viewvc/qooxdoo?view=rev&revision=13840
>
> You changed from a loop version to a recursive version.
>
> The recursive version will be very inefficient. It will use up loads more
> memory for long paths (as there are local variables for each call of the
> function), and take a lot more time as you are slicing the input strings
> with each call.
>
> It's neat but hardly optimal.
>
>
Hi Hugh,
uhm, I thought about that, too, but was quite confident that the runtime
penalty would be subliminal, given the limited nature of file system
paths. Even a non-tail-recursion-optimized CPython should be fast enough
on modern hardware for a path of 1,000 characters and 200 directory
elements. But if you experience real impediments get back to me (the
loop version is still in the code so you can flip them and experiment),
I could e.g. cut down in local variables using an index into the
strings. Personally I haven't "felt" any perfomance hits after the
change in my environment (but I have to admit I'm using Stackless).
> Why not use os.path.commonprefix to find the common prefix, and then
> return the two trailing parts by just taking the length of the common
> prefix? Probably faster as it's a library routine anyway.
>
Good point, but one of the reasons I have this self-written routine is
that os.path.commonprefix is unfortunately purely string-oriented and
not directory-aware. Check the return value of
os.path.commonprefix(['a/b.1/c', 'a/b.2/d'])
which is 'a/b.', which defeats its use for my purposes. It's paths after
all, not strings.
Thomas
> Hugh
>
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php
> _______________________________________________
> qooxdoo-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>
>
>
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel