[Python-ideas] BetterWalk, a better and faster os.walk() for Python

Ben Hoyt benhoyt at gmail.com
Thu Nov 22 21:23:51 CET 2012


> On Mageia Linux 1, I had the following results:
> - Python 2.7: 0.7x as fast
> - Python 3.2: 1.1x as fast
> - Python 3.3: 1.2x as fast
> The -s flag didn't make a difference.

Thanks. Out of interest, 64 bit or 32 bit (system and Python)?

I wonder if ctypes got significantly faster in Python 3.x, or what's
going on here. Python 3 is significantly faster in my tests too --
noticeable on Linux.

> Do note that the benchmark is very fast - around ~40 ms for a walk.

Yeah, that's over too quickly for a real test, isn't it? I'm already
creating a 230MB dir, but maybe I need to add more, smaller files.
Easy to tweak with the NUM_FILES and NUM_DIRS constants (though you'll
need to delete your current "benchtree" dir so it recreates it. Maybe
I should bump up the defaults too.

-Ben



More information about the Python-ideas mailing list