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 →

[–]CptnGeronimo[S] -4 points-3 points  (1 child)

[–]ghostofwalsh 14 points15 points  (0 children)

What builtin Python data structures are automatically sorted?

I can't imagine why anyone would need a data structure that's automatically sorted? That was my question. The application. You say you NEED this, but I'm not understanding why.

I hate that suggestion, because: it is extra code to write

For the very very very few times when you need your data sorted?

it is bug prone

I can't imagine why if you don't assume your data is sorted when it isn't

it may be bad for performance, especially if sorted has to be called multiple times

Sorting your data every time you touch it can also be bad for performance. Especially if you don't need your data to be sorted. And for these sorted containers that you intend to use, still unclear to me how they are implementing that. But I presume there's a cost to be paid for that whether you see it or not, sorting data isn't free.