[Python-ideas] set.add(x) slower than if x in set:set.add(x)
Marcin 'Qrczak' Kowalczyk
qrczak at knm.org.pl
Tue Sep 15 19:58:20 CEST 2009
2009/9/14 Nick Coghlan <ncoghlan at gmail.com>:
> The interpreter has no way of knowing a priori that the branch won't be
> taken 999,999 times out of 1,000,000.
And it does not know a priori that s.add(x) will involve checking
whether the set s contains x. It does not even try to infer that s
must be a set at this point.
--
Marcin Kowalczyk
qrczak at knm.org.pl
http://qrnik.knm.org.pl/~qrczak/
More information about the Python-ideas
mailing list