A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-April/034772.html below:

summing a bunch of numbers (or "whatevers")

[Python-Dev] Fwd: summing a bunch of numbers (or "whatevers")Michael Hudson mwh@python.net
Sun, 20 Apr 2003 00:10:48 +0100
Jack Jansen <Jack.Jansen@oratrix.com> writes:

> Do you have any idea why your sum function is, uhm, three times
> faster than the reduce(operator.add) version? Is the implementation
> of reduce doing something silly, or are there shortcuts you can take
> that reduce() can't?

I imagine it's the function calls; a trip through the call machinery,
time packing and unpacking arguments, etc.  I haven't checked, though.

> I'm asking because I think I would prefer reduce to give the speed
> you want.  That way, we won't have people come asking for a prod()
> function to match sum(), etc.

I can't think of one.

I'm not sure this is worth the effort, though.

Cheers,
M.

-- 
  Any form of evilness that can be detected without *too* much effort
  is worth it...  I have no idea what kind of evil we're looking for
  here or how to detect is, so I can't answer yes or no.
                                       -- Guido Van Rossum, python-dev



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4