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 sorting dict items #392

Merged
merged 4 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

- Drop support for Python 2.7, 3.5, 3.6.

- Fix sorting of dict items in script space (py3 not OK with py2 syntax)


5.8.1 (2023-07-18)
==================
Expand Down
6 changes: 3 additions & 3 deletions src/ZODB/scripts/space.py
Original file line number Diff line number Diff line change
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