-
Notifications
You must be signed in to change notification settings - Fork 2
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
Move repository into sat #110
Conversation
This Repository class is a simplified version of the one in enstaller. It also improves on the enstaller one by supporting deterministic iteration: for a given set of packages, iterating over the repository will always yield the packages in the same order, independently of how packages were added.
self._name_to_packages[package_metadata.name].append(package_metadata) | ||
# Fixme: this should not be that costly as long as we don't have | ||
# many versions for a given package. | ||
self._name_to_packages[package_metadata.name].sort( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the argument against making PackageMetadata orderable and using insort
here too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the definition of PackageMetadata, the sorting would occur on (name, version, dependencies, python_tag)
, which I think would be acceptable here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I benchmarked that for small sequences, sorting every time is faster than calling insort, but let me check again since a lot of the code changed since.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so there is no measurable speed change in my limited test, but to work properly, it requires a change in PackageMetadata
(as they are not orderable ATM). Since I will rewrite PackageMetadata
to be in SAT, I would suggest to make that change then
One question, otherwise LGTM |
|
||
class Repository(object): | ||
""" | ||
A Repository is a set of package, and knows about which package it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"packages"
We also return a tuple instead of a list in find_packages, so that the output is 'naturally' immutable.
LGTM |
This PR implements a simplified
Repository
class to replace the enstaller one in simplesat:PackageMetadata
subclassfind_package*
andupdate
methods.This is the penultimate PR to remove the dependency on enstaller. The last one will implement a leaner
PackageMetadata
class.@johntyree