Categories
How to quickly find an object in the list?
Now it works like this, but it will be very slow when there are more servers
for server in self.servers: if server.id == id: return server
Answer the question
In order to leave comments, you need to log in
If your list does not have a billion servers, then no, it will not be slow. But if you really want to, then a typical tactic is to make a lookup_field: object dictionary. If you absolutely need lists, you can use the bisect module.
Didn't find what you were looking for?
Ask a Question
731 491 924 answers to any question