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

Antoine Pitrou solipsis at pitrou.net
Thu Nov 22 21:29:03 CET 2012


On Fri, 23 Nov 2012 09:23:51 +1300
Ben Hoyt <benhoyt at gmail.com> wrote:
> > 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)?

64 bit.

> 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.

Since you're using a ctypes solution, it's difficult to compare against
built-in listdir() and stat() (which are written in C). So I'd suggest
either rewriting your core function in C (better), or using a ctypes
emulation of listdir() and stat() (easier?).

Regards

Antoine.





More information about the Python-ideas mailing list