Re:I don't like Python. Does that make me a bad person?
by pjscott on Saturday June 26, 2010 @06:19PM
(#1464391)
I didn't mean to imply that lacking a sorted set datatype wasn't a pain in the ass; I was pointing out that the lack of multiple set implementations is a tradeoff that we make for all built-in datatypes that could support other operations but don't. (Personally, I would love to have the ability to pick a random element from a set. That would be great.)
By the way, in case anybody was wondering, here is a (relatively inefficient) way of making a sorted set in python:
Re:I don't like Python. Does that make me a bad person?
by silvertab on Saturday June 26, 2010 @08:15PM
(#1464561)
Couldn't you just do the following?
from random import choice
choice(list(myset))
(I'm guessing you'd want to do it without having to convert it to a list first?)
Re:I don't like Python. Does that make me a bad person?
by pjscott on Sunday June 27, 2010 @04:32AM
(#1465215)
That's what I ended up doing, but this was happening with a very large set, right in an inner loop. Luckily this was running in batch mode, so I could go get lunch or something instead of taking the time to make it faster.
1. I love python.
2. The OP was being a troll.
3. People need to be more honest about themselves and their favorite pet languages. I can write a sorted set in assembler too, if I wanted. However, there's been several times that I've wanted a sorted set data type while coding in Python but found that none was easily available. I hate the, "you can write your own!" counterpoint, because it is essentially meaningless unless you can prove that writing your own is as trivial as importing someone else's implementation.