Remove O(N^2) operation from NumberedObjectCollection #556
Labels
feature request
An issue that improves the user interface.
performance 🐌
Issues related to speed and memory
Is your feature request related to a problem? Please describe.
I was analyzing some data from parsing times and found that we have O(N^2) scaling despite fixing #510. After some investigation I found the culprit is in
NumberedObjectCollections.append
. This runs through all ofself.numbers
every time which is a generator over the entire list.... O(N^2).So this should be eliminated.
Describe the solution you'd like
A few solutions.
read_input
and do a bulk add that is optimizedNumberedObjectCollection
a lot more like dicts, and rely on__num_cache
a lot more. Through the number property we guarantee that numbers are always update for objects tied to problem. So maybe we use this O(n^2) operation only as a last resot.The text was updated successfully, but these errors were encountered: