Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upOptimizing list.insert(0, v) #2276
Conversation
… be an O(n^2) algorithm per https://docs.python.org/3/library/collections.html#collections.deque. "Though list objects support similar operations, they are optimized for fast fixed-length operations and incur O(n) memory movement costs for pop(0) and insert(0, v) operations which change both the size and position of the underlying data representation." Changed to a deque to be O(n)
TravisBuddy
commented
Aug 3, 2020
|
Hey @Omarfos, TravisCI finished with status TravisBuddy Request Identifier: e489c980-d5df-11ea-8ca9-c37e1b84d109 |
|
Travis CI is failing, make sure that the tests pass |
|
@Omarfos Build log says:
Really easily fixable. Also you can |
|
Thank you @spamegg1, should be good to merge now |
|
Please add a |
|
Needs a https://docs.python.org/3.8/library/timeit.html benchmark. |
Omarfos commentedAug 3, 2020
Initially, there was a call to "binary.insert(0, num % 2)", this woud be an O(n^2) algorithm per
https://docs.python.org/3/library/collections.html#collections.deque.
"Though list objects support similar operations, they are optimized for
fast fixed-length operations and incur O(n) memory movement costs for
pop(0) and insert(0, v) operations which change both the size and
position of the underlying data representation."
Changed to a deque to be O(n)
Describe your change:
Checklist:
Fixes: #{$ISSUE_NO}.