Is it just Syntactic Sugar ?
Eric Hagemann
ehagemann at home.com
Mon May 22 21:26:40 EDT 2000
Based on some recent code I have been writing I am courious on
describing the following as 'syntactic sugar'
a common operation is to
a=a+1
which in C can be written as
a+=1
in its simplest form I agree there might not be much to this but if you
do this with a complex expression as
a[x][f][g] = a[x][f][g] + 1
does the python engine recompute the 'address' of the variable 'a[x][f][g]'
twice ?
Would the a+=1 for speed things up or is it just expanded to a=a+1 anyway ?
I have found that
p=a[x][f][g]
p=p+1
is faster than above so I kinda believe the 'address' is computed twice (I
am leaping here)
Comments / Thoughts ?
Cheers
Eric
P.S. The application, if you are wondering is to generate counts of events
in log files
the events have various dimensions such as date/time/orgin that I catalog
them by
More information about the Python-list
mailing list