Skip to content

Commit

Permalink
scripts/space.py: fix sorting dict items (#392)
Browse files Browse the repository at this point in the history
Co-authored-by: Jens Vagelpohl <jens@plyp.com>
Co-authored-by: Michael Howitz <icemac@gmx.net>
  • Loading branch information
3 people committed Oct 10, 2023
1 parent 17be4a7 commit f142393
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Expand Up @@ -9,6 +9,8 @@

- Drop support for Python 2.7, 3.5, 3.6.

- Fix sorting issue in ``scripts/space.py``.


5.8.1 (2023-07-18)
==================
Expand Down
6 changes: 3 additions & 3 deletions src/ZODB/scripts/space.py
Expand Up @@ -8,6 +8,8 @@
Current limitations / simplifications: Ignores revisions and versions.
"""

from operator import itemgetter

from ZODB.FileStorage import FileStorage
from ZODB.utils import U64
from ZODB.utils import get_pickle_metadata
Expand All @@ -32,9 +34,7 @@ def run(path, v=0):
totals[key] = bytes, count
if v:
print("%8s %5d %s" % (U64(oid), len(data), key))
L = totals.items()
L.sort(key=lambda x: x[1])
L.reverse()
L = sorted(totals.items(), key=itemgetter(1), reverse=True)
print("Totals per object class:")
for key, (bytes, count) in L:
print("%8d %8d %s" % (count, bytes, key))
Expand Down

0 comments on commit f142393

Please sign in to comment.