Find in ipython3

Cameron Simpson cs at zip.com.au
Sun Jun 7 03:38:23 EDT 2015


On 07Jun2015 08:20, Cecil Westerhof <Cecil at decebal.nl> wrote:
>There is no gain to get in standard Python? By switching from fnmatch
>to re I got almost a speed gain of two. So I was wondering if I could
>do more.

Maybe write a few versions: one really dumb using filename == matchstring (like 
-name foo), one using filename.startswith(matchstring) (like -name '*foo'), one 
using matchstring in filename (like -name '*foo*') and your current one. See 
how much these affect the runtime. You _will_ need to make multiple identical 
runs (OSes do lots of caching, and other processes competing for I/O or the CPU 
will also perturb things).

One the topic of multiple runs, have a look at the timeit module, psecificly 
designed for testing code with multiple runs.

Cheers,
Cameron Simpson <cs at zip.com.au>



More information about the Python-list mailing list