Skip to content

[FIX] Table.from_table: fix caching with reused ids #4370

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

Merged
merged 2 commits into from
Feb 1, 2020

Conversation

markotoplak
Copy link
Member

Issue

In Table.from_table id() of objects are used as cache keys. Because ids can be reused this can be a problem.

Description of changes

If keys were not tuples we could use WeakKeyDictionary for cache, but here, because they are, I store weakrefs to original objects as values. The cached value is not used if the objects these weakrefs are pointing to do not exists anymore.

Includes
  • Code changes
  • Tests
  • Documentation

EfficientTransformTests count calls to compute_values.
@markotoplak markotoplak changed the title From table cache less [FIX] Table.from_table: fix caching with reused ids Jan 27, 2020
In Table.from_table id() of objects are used as cache keys. Because
ids can be reused this can be a problem. If keys were not tuples
we could use WeakKeyDictionary for cache, but here, because they are, I
store weakrefs to original objects as values. The cached value is not
used if the objects these weakrefs are pointing to do not exists anymore.
@markotoplak markotoplak force-pushed the from_table-cache-less branch from e517c0f to b175dfa Compare January 27, 2020 13:48
@codecov
Copy link

codecov bot commented Jan 27, 2020

Codecov Report

Merging #4370 into master will increase coverage by 0.03%.
The diff coverage is 91.66%.

@@            Coverage Diff             @@
##           master    #4370      +/-   ##
==========================================
+ Coverage    87.1%   87.13%   +0.03%     
==========================================
  Files         399      399              
  Lines       72762    72907     +145     
==========================================
+ Hits        63376    63530     +154     
+ Misses       9386     9377       -9

@janezd janezd self-assigned this Jan 31, 2020
@janezd janezd merged commit 796bd26 into biolab:master Feb 1, 2020
@markotoplak markotoplak deleted the from_table-cache-less branch February 5, 2020 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants