|
|
|
|
|
by zhd
2036 days ago
|
|
Bisect is nice, but it's not the fastest option. If binning data, discretize it and then use a dict lookup - `grades_to_letters[grade//10]`, for example. For insort, and indeed anything with sorted collections, just use the http://www.grantjenks.com/docs/sortedcontainers/ module. Inserting an element is worst-case sublinear time, and also faster than C-extensions. It's one of the very few data-structure libraries I use regularly. |
|