Skip to content

Instantly share code, notes, and snippets.

@adamsilkey
adamsilkey / gist:4560921
Last active December 11, 2015 06:39 — forked from benhoyt/gist:4044946
"""Speed up os.walk() significantly by using file attributes that
FindFirst/Next give us instead of doing an extra stat(). Can also do the same
thing with opendir/readdir on Linux.
This is doubly useful when the user (caller of os.walk) is doing *another*
stat() to get say the file sizes.
On my tests (Windows 64-bit) our walk() is about 5x as fast as os.walk() for
large directory trees, and 9x as fast if you're doing the file size thing.
Note that these timings are "once it's in the cache", not first-time timings.
@adamsilkey
adamsilkey / re.__init__.py.patch
Created December 14, 2023 21:54
Adding pos/endpos to re
diff --git a/__init__.py b/__init__.py
index 4515650..14140b2 100644
--- a/__init__.py
+++ b/__init__.py
@@ -125,6 +125,7 @@ import enum
from . import _compiler, _parser
import functools
import _sre
+import sys