Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0d530ce

Browse files
committed
Faster implementation of normcase (using string.lower(
string.replace(...)) instead of a for loop). Don't call normcase() in normpath() -- the filesystem just might be case preserving...
1 parent 505d80b commit 0d530ce

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

Lib/dospath.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,7 @@
1515
# possibly be added as a new function.
1616

1717
def normcase(s):
18-
res, s = splitdrive(s)
19-
for c in s:
20-
if c in '/\\':
21-
res = res + os.sep
22-
else:
23-
res = res + c
24-
return string.lower(res)
18+
return string.lower(string.replace(s, "/", "\\"))
2519

2620

2721
# Return wheter a path is absolute.
@@ -316,7 +310,7 @@ def expandvars(path):
316310
# Also, components of the path are silently truncated to 8+3 notation.
317311

318312
def normpath(path):
319-
path = normcase(path)
313+
path = string.replace(path, "/", "\\")
320314
prefix, path = splitdrive(path)
321315
while path[:1] == os.sep:
322316
prefix = prefix + os.sep

0 commit comments

Comments
 (0)