The point of choosing one implementation over another is not necessarily related to the upper bound , but rather the expected amortized performance . While different algorithms may have degenerate cases, this is usually "better in practice" than using an approach with a provable lower bound. In some cases, however, structures must be designed to protect against pathologically poor input.
In addition, some languages / libraries - not sure about Python - actually change the underlying implementation, for example, when the number of elements exceeds low n. This affects amortized performance (in some cases), but not necessarily large O.
And in conclusion: "It depends."
Happy coding.
user166390
source share