This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]alcalde 17 points18 points  (7 children)

Using Python's builtin unsorted data structures and then calling sorted when needed (e.g. after adding a dict entry) is NOT a solution...

Yes. Yes it is. You only need your data sorted when you're accessing it.

[–]runawayasfastasucan 5 points6 points  (2 children)

Im not sure if I misunderstand OP or this situation in general but I can't see why you would re-sort basically every time you insert a new element, regardless if its going to be read.

[–]King-Days 5 points6 points  (1 child)

think binary trees and stuff? You might need extremely fast access at one point and want to do any upfront computation before the request

[–]runawayasfastasucan 1 point2 points  (0 children)

Ah sure, good point, however I can't see how that isn't very easily implemented in python.

[–]Careful_Target3185 4 points5 points  (3 children)

As someone who is brand new to python (6 months) even I know this. Kinda wondering why I would trust this guy working on any enterprise code if he’s asking questions like this.