diff options
author | Mathieu Bridon <[email protected]> | 2018-08-09 10:27:23 +0200 |
---|---|---|
committer | Dylan Baker <[email protected]> | 2018-08-09 16:49:19 -0700 |
commit | 8d3ff6244c7cc5a8399afcf0d1d98d7fd8148452 (patch) | |
tree | 5dd34e5fdc175bb70c470c86e430fbe6d3f65329 /src/loader | |
parent | 1e668ca111563b122b16be5506638983b31205b5 (diff) |
python: Use key-functions when sorting containers
In Python 2, the traditional way to sort containers was to use a
comparison function (which returned either -1, 0 or 1 when passed two
objects) and pass that as the "cmp" argument to the container's sort()
method.
Python 2.4 introduced key-functions, which instead only operate on a
given item, and return a sorting key for this item.
In general, this runs faster, because the cmp-function has to get run
multiple times for each item of the container.
Python 3 removed the cmp-function, enforcing usage of key-functions
instead.
This change makes the script compatible with Python 2 and Python 3.
Signed-off-by: Mathieu Bridon <[email protected]>
Reviewed-by: Eric Engestrom <[email protected]>
Reviewed-by: Dylan Baker <[email protected]>
Diffstat (limited to 'src/loader')
0 files changed, 0 insertions, 0 deletions