[PATCH] dirstate: pass the dict to modify to statfiles

Matt Mackall mpm at selenic.com
Sat Dec 1 10:57:17 CST 2012


On Fri, 2012-11-30 at 17:01 -0800, Bryan O'Sullivan wrote:
> On Fri, Nov 30, 2012 at 4:57 PM, Matt Mackall <mpm at selenic.com> wrote:
>         Looks suspicious: statfiles only has accessed to the join()ed
>         version of
>         visit.
>         
> 
> Yes, you're right. Oops.

Proposed API:

 results.update(util.statfiles(basepath, visitlist, ignorespecial=True))

Here, statfiles generates a list of (visitfile, stat) pairs, doing the
join internally. The ignorespecial flag ignores anything but files and
symlinks.

In principle, this should be pretty low overhead, even compared to
passing in a dict:

$ python -m timeit -s 'a, b = dict.fromkeys(range(100000)),
dict.fromkeys(range(1000000))' -c 'a.update(b)'
10 loops, best of 3: 25 msec per loop

$ python -m timeit -s 'a, b = dict.fromkeys(range(100000)),
dict.fromkeys(range(1000000))' -c 'a.update(b.iteritems())'
10 loops, best of 3: 37 msec per loop

Unfortunately, this is a bit of a nuisance to implement as it's a
generator.

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list