To count number of quadruplets with sum = 0
Steven Bethard
steven.bethard at gmail.com
Fri Mar 16 11:37:28 EDT 2007
Marc 'BlackJack' Rintsch wrote:
> In <7x6491k9t3.fsf at ruckus.brouhaha.com>, Paul Rubin wrote:
>
>> "n00m" <n00m at narod.ru> writes:
>>> h = collections.defaultdict(itertools.repeat(0).next)
>> Something wrong with
>> h = collections.defaultdict(int)
>> ?????
>
> According to a post by Raymond Hettinger it's faster to use that iterator
> instead of `int`.
Yep. It's because the .next() method takes no arguments, while int()
takes varargs because you can do::
int('2')
int('2', 8)
Calling a no-args function is substantially faster than calling a
varargs function.
STeVe
More information about the Python-list
mailing list