Message199032
| Author |
smichr |
| Recipients |
eric.araujo, ezio.melotti, georg.brandl, michael.driscoll, orsenthil, python-dev, rhettinger, sandro.tosi, smichr, tim.peters |
| Date |
2013年10月06日.06:44:45 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<CAEPTCsNA8t9XPcKsRY9w6BawmRPJEaGoxOr+7MSfTYWW2+r=gA@mail.gmail.com> |
| In-reply-to |
<1381036484.68.0.505839833504.issue14927@psf.upfronthosting.co.za> |
| Content |
On Sun, Oct 6, 2013 at 12:14 AM, Raymond Hettinger
<report@bugs.python.org>wrote:
>
> Raymond Hettinger added the comment:
>
> Christopher, this tracker item needs to die. It is wasting everyone's
> time (and churning code) over nothing.
>
>
but it's not quite dead yet...
> FYI, I moved the _int=int for shuffle inside the function because the
> assignment was outside of the inner loop, so we weren't getting any real
> benefit.
>
but cf Tim's comment regarding the advantage of leaving it in the arg list
so that the lookup is fast:
[Senthil Kumaran]
> I am unaware of the optimization technique you refer to as
> well, it will helpful if you could point to any resource.
It's an old trick since the very first Pythons: global lookups are
much slower than local lookups (the difference between the LOAD_GLOBAL
and LOAD_FAST opcodes in CPython). Putting:
..., _fast=slow, ...
in an argument list means we endure the slow lookup (of `slow`) only
once, when the function is first defined. When the function is
_called_, that binding is available via the local (much faster lookup)
variable `_fast`.
Purely a speed trick, but can make a real difference in very heavily
used functions.
----------
So by removing it from the arg list you have perhaps caused a regression in
performance of shuffle. Other than that, everything looks fine to me.
Thanks,
Chris |
|