Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.buildout
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
6
Merge Requests
6
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
slapos.buildout
Commits
638d92a4
Commit
638d92a4
authored
May 21, 2020
by
Godefroid Chapelle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Problem: slow pkg_resources.Distribution.hashcmp
Solution: cache it
parent
16f9b863
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
32 deletions
+13
-32
CHANGES.rst
CHANGES.rst
+1
-1
src/zc/buildout/patches.py
src/zc/buildout/patches.py
+12
-31
No files found.
CHANGES.rst
View file @
638d92a4
...
@@ -4,7 +4,7 @@ Change History
...
@@ -4,7 +4,7 @@ Change History
3.0.0
a2
(
unreleased
)
3.0.0
a2
(
unreleased
)
====================
====================
-
Nothing
changed
yet
.
-
Better
patch
for
``
pkg_resources
.
Distribution
.
hashcmp
``
performance
.
3.0.0
a1
(
2020
-
05
-
17
)
3.0.0
a1
(
2020
-
05
-
17
)
...
...
src/zc/buildout/patches.py
View file @
638d92a4
...
@@ -15,41 +15,22 @@
...
@@ -15,41 +15,22 @@
def
patch_Distribution
():
def
patch_Distribution
():
try
:
try
:
from
pkg_resources
import
_remove_md5_fragment
from
pkg_resources
import
Distribution
from
pkg_resources
import
Distribution
if
hasattr
(
Distribution
,
'location'
):
return
# prepare any Distribution built before monkeypatch
from
pkg_resources
import
working_set
for
dist
in
working_set
:
dist
.
_location
=
dist
.
location
dist
.
_location_without_md5
=
_remove_md5_fragment
(
dist
.
location
)
def
hashcmp
(
self
):
def
hashcmp
(
self
):
without_md5
=
getattr
(
self
,
'_location_without_md5'
,
''
)
if
hasattr
(
self
,
'_hashcmp'
):
return
(
return
self
.
_hashcmp
self
.
parsed_version
,
else
:
self
.
precedence
,
self
.
_hashcmp
=
result
=
(
self
.
key
,
self
.
parsed_version
,
without_md5
,
self
.
precedence
,
self
.
py_version
or
''
,
self
.
key
,
self
.
platform
or
''
,
self
.
location
,
)
self
.
py_version
or
''
,
self
.
platform
or
''
,
def
get_location
(
self
):
)
try
:
return
result
result
=
self
.
_location
except
AttributeError
:
result
=
''
return
result
def
set_location
(
self
,
l
):
self
.
_location
=
l
self
.
_location_without_md5
=
_remove_md5_fragment
(
l
)
setattr
(
Distribution
,
'location'
,
property
(
get_location
,
set_location
))
setattr
(
Distribution
,
'hashcmp'
,
property
(
hashcmp
))
setattr
(
Distribution
,
'hashcmp'
,
property
(
hashcmp
))
except
ImportError
:
except
ImportError
:
return
return
...
...
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