Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix caching of file-categorization logic #1044

Merged
merged 1 commit into from Dec 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTING.rst
Expand Up @@ -163,6 +163,7 @@ their individual contributions.
* `Alex Stapleton <https://www.github.com/public>`_
* `Alex Willmer <https://github.com/moreati>`_ (alex@moreati.org.uk)
* `Ben Peterson <https://github.com/killthrush>`_ (killthrush@hotmail.com_)
* `Buck Evan, copyright Google LLC <https://github.com/bukzor>`_
* `Charles O'Farrell <https://www.github.com/charleso>`_
* `Charlie Tanksley <https://www.github.com/charlietanksley>`_
* `Chris Down <https://chrisdown.name>`_
Expand Down
4 changes: 4 additions & 0 deletions RELEASE.rst
@@ -0,0 +1,4 @@
RELEASE_TYPE: patch

This release fixes :issue:`1044`, which slowed tests by up to 6%
due to broken caching.
10 changes: 6 additions & 4 deletions src/hypothesis/internal/escalation.py
Expand Up @@ -34,13 +34,15 @@ def belongs_to(package):
cache = {text_type: {}, binary_type: {}}

def accept(filepath):
ftype = type(filepath)
try:
return cache[type(filepath)][filepath]
return cache[ftype][filepath]
except KeyError:
pass
filepath = encoded_filepath(filepath)
result = os.path.abspath(filepath).startswith(root)
cache[type(filepath)][filepath] = result
new_filepath = encoded_filepath(filepath)
result = os.path.abspath(new_filepath).startswith(root)
cache[ftype][filepath] = result
cache[type(new_filepath)][new_filepath] = result
return result
accept.__name__ = 'is_%s_file' % (package.__name__,)
return accept
Expand Down