Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
649f8e7d
Commit
649f8e7d
authored
Aug 03, 2005
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
patch [ 1105730 ] Faster commonprefix in macpath, ntpath, etc.
parent
b3700592
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
41 deletions
+35
-41
Lib/macpath.py
Lib/macpath.py
+8
-8
Lib/ntpath.py
Lib/ntpath.py
+7
-8
Lib/os2emxpath.py
Lib/os2emxpath.py
+7
-8
Lib/plat-riscos/riscospath.py
Lib/plat-riscos/riscospath.py
+10
-17
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/macpath.py
View file @
649f8e7d
...
...
@@ -175,14 +175,14 @@ def lexists(path):
def
commonprefix
(
m
):
"Given a list of pathnames, returns the longest common leading component"
if
not
m
:
return
''
prefix
=
m
[
0
]
for
item
in
m
:
for
i
in
range
(
len
(
prefix
)):
if
prefix
[:
i
+
1
]
!=
item
[:
i
+
1
]
:
prefix
=
prefix
[:
i
]
if
i
==
0
:
return
''
break
return
prefix
s1
=
min
(
m
)
s2
=
max
(
m
)
n
=
min
(
len
(
s1
),
len
(
s2
))
for
i
in
xrange
(
n
)
:
if
s1
[
i
]
!=
s2
[
i
]:
return
s1
[:
i
]
return
s1
[:
n
]
def
expandvars
(
path
):
"""Dummy to retain interface-compatibility with other operating systems."""
...
...
Lib/ntpath.py
View file @
649f8e7d
...
...
@@ -212,14 +212,13 @@ def dirname(p):
def
commonprefix
(
m
):
"Given a list of pathnames, returns the longest common leading component"
if
not
m
:
return
''
prefix
=
m
[
0
]
for
item
in
m
:
for
i
in
range
(
len
(
prefix
)):
if
prefix
[:
i
+
1
]
!=
item
[:
i
+
1
]:
prefix
=
prefix
[:
i
]
if
i
==
0
:
return
''
break
return
prefix
s1
=
min
(
m
)
s2
=
max
(
m
)
n
=
min
(
len
(
s1
),
len
(
s2
))
for
i
in
xrange
(
n
):
if
s1
[
i
]
!=
s2
[
i
]:
return
s1
[:
i
]
return
s1
[:
n
]
# Get size, mtime, atime of files.
...
...
Lib/os2emxpath.py
View file @
649f8e7d
...
...
@@ -173,14 +173,13 @@ def dirname(p):
def
commonprefix
(
m
):
"Given a list of pathnames, returns the longest common leading component"
if
not
m
:
return
''
prefix
=
m
[
0
]
for
item
in
m
:
for
i
in
range
(
len
(
prefix
)):
if
prefix
[:
i
+
1
]
!=
item
[:
i
+
1
]:
prefix
=
prefix
[:
i
]
if
i
==
0
:
return
''
break
return
prefix
s1
=
min
(
m
)
s2
=
max
(
m
)
n
=
min
(
len
(
s1
),
len
(
s2
))
for
i
in
xrange
(
n
):
if
s1
[
i
]
!=
s2
[
i
]:
return
s1
[:
i
]
return
s1
[:
n
]
# Get size, mtime, atime of files.
...
...
Lib/plat-riscos/riscospath.py
View file @
649f8e7d
...
...
@@ -168,23 +168,16 @@ def dirname(p):
return
split
(
p
)[
0
]
def
commonprefix
(
ps
):
"""
Return the longest prefix of all list elements. Purely string-based; does not
separate any path parts. Why am I in os.path?
"""
if
len
(
ps
)
==
0
:
return
''
prefix
=
ps
[
0
]
for
p
in
ps
[
1
:]:
prefix
=
prefix
[:
len
(
p
)]
for
i
in
range
(
len
(
prefix
)):
if
prefix
[
i
]
<>
p
[
i
]:
prefix
=
prefix
[:
i
]
if
i
==
0
:
return
''
break
return
prefix
def
commonprefix
(
m
):
"Given a list of pathnames, returns the longest common leading component"
if
not
m
:
return
''
s1
=
min
(
m
)
s2
=
max
(
m
)
n
=
min
(
len
(
s1
),
len
(
s2
))
for
i
in
xrange
(
n
):
if
s1
[
i
]
!=
s2
[
i
]:
return
s1
[:
i
]
return
s1
[:
n
]
## File access functions. Why are we in os.path?
...
...
Misc/NEWS
View file @
649f8e7d
...
...
@@ -178,6 +178,9 @@ Extension Modules
Library
-------
-
Patch
#
1105730
:
Apply
the
new
implementation
of
commonprefix
in
posixpath
to
ntpath
,
macpath
,
os2emxpath
and
riscospath
.
-
Fix
a
problem
in
Tkinter
introduced
by
SF
patch
#
869468
:
delete
bogus
__hasattr__
and
__delattr__
methods
on
class
Tk
that
were
breaking
Tkdnd
.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment