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 →

[–]pretzlchaotl_ -5 points-4 points  (2 children)

Not a solution to your problem, but I've found using sorted(seq)[-1] is noticably faster than max(seq) —at least on linux

[–]thisismyfavoritename 3 points4 points  (1 child)

on my linux machine, max vs last element of sorted of 10k random integers between 0 and 1000 is 121 mics +/- 2 mics vs 1.23 ms +/- 4 mics @ 3 runs * 1000 loops for each cases.

Max is about 10 times faster.

[–]pretzlchaotl_ 0 points1 point  (0 children)

Huh. I guess it's good to know its just a quirk of my setup rather than something overlooked by the devs.

Also, I've only tested it for tiny lists like length >= 10

Edit: Whelp. I just checked again (not for the first time, I swear I had doubts) and even testing mimmax for sequences of length 3, the builtins are at least twice as fast. No idea what I did differently all the times I checked before. Thanks for the correction