Skip to content

Commit

Permalink
Use Counter() not defaultdict(int)
Browse files Browse the repository at this point in the history
This appears to solve an apparent memory leak.
  • Loading branch information
peterjc committed Dec 15, 2022
1 parent 4bcda3f commit 3b5dd79
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions thapbi_pict/sample_tally.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ def main(
assert marker

totals = Counter()
counts = defaultdict(int)
sample_counts = defaultdict(int)
counts = Counter()
sample_counts = Counter()
sample_cutadapt = {} # before any thresholds
samples = set()
sample_pool = {}
Expand Down

1 comment on commit 3b5dd79

@peterjc
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a memory leak exactly, rather down to the documented behaviour of defaultdict which is to add novel keys to the dictionary with the default value. I did not want that to happen.

Inspiration for PyCQA/flake8-bugbear#323

Please sign in to comment.