Re: Bicycle Repair Man usability
- From: "Fredrik Lundh" <fredrik@xxxxxxxxxxxxxx>
- Date: Wed, 31 Aug 2005 15:22:07 +0200
Kay Schluehr wrote:
> Instead of writing f(g(h(...))) it is sometimes adaequate to write
>
> x = h(...)
> f(g(x))
>
> I use this a lot in particular in C++. Optimzing compilers eliminate
> runtime penalties. This is of course different in CPython.
if "x" is a local variable, the penality isn't that huge:
$ timeit "id(len(str(0)))"
1000000 loops, best of 3: 0.911 usec per loop
$ timeit "x = str(0); id(len(x))"
1000000 loops, best of 3: 0.968 usec per loop
globals are slower:
$ timeit -s "global x" "x = str(0); id(len(x))"
1000000 loops, best of 3: 1.26 usec per loop
</F>
.
- References:
- Bicycle Repair Man usability
- From: Rex Eastbourne
- Re: Bicycle Repair Man usability
- From: Sybren Stuvel
- Re: Bicycle Repair Man usability
- From: Kay Schluehr
- Bicycle Repair Man usability
- Prev by Date: Re: .pth files in working directory
- Next by Date: Re: module not found in IIS virtual dir
- Previous by thread: Re: Bicycle Repair Man usability
- Next by thread: Re: Bicycle Repair Man usability
- Index(es):
Relevant Pages
|
|