Python in operator revisited
02.05.2008 19:38
Hruške has some well founded arguments against my last Python performance rant.
I stand corrected. I must have messed something up with my measurements. I have now repeated them on two different machines and I got the same results as Hruške. So the in operator in Python is indeed fast when the right hand operand is a dictionary.
I can only say in my defense that I thought that this part of Python documentation confirms that the in operator works in a general way on all iterable objects:
__iter__()
Return the iterator object itself. This is required to allow both containers and iterators to be used with the for and in statements. This method corresponds to the tp_iter slot of the type structure for Python objects in the Python/C API.
As for his other comment about Wikiprep code size:
avian@toybox:~/dev/html2latex-1.1$ sloccount . ... snip ... Totals grouped by language (dominant language first): perl: 797 (100.00%) Total Physical Source Lines of Code (SLOC) = 797
avian@toybox:~/dev/wikiprep$ sloccount . ... snip ... Totals grouped by language (dominant language first): perl: 2060 (85.12%) cpp: 220 (9.09%) python: 50 (2.07%) ansic: 49 (2.02%) sh: 41 (1.69%) Total Physical Source Lines of Code (SLOC) = 2,420
So yeah, Wikiprep Perl code which I maintain for Zemanta is still bigger.
That of course doesn't mean that there aren't any bigger Perl monstrosities in the wild. After a quick survey of free Perl software I have on the disk I found gtablix which has 6283 Perl SLOC and GCfilms with an unbelievable 25758 Perl SLOC (neither of which seems to be maintained BTW).
