Python exceptions and refcounts

Kragen Sitaker kragen at pobox.com
Wed Jan 23 16:46:10 EST 2002


"Alex Martelli" <aleax at aleax.it> writes:
> "Kragen Sitaker" <kragen at pobox.com> wrote in message
> news:83y9ip4deh.fsf at panacea.canonical.org...
> >     finally: self.ii = self.ii + 1
> >
> > In the absence of exceptions, both will do the same thing.
> >
> > I'm not sure this is an actual improvement; I think I may be
> > succumbing to the Premature Optimization Demon, in its worst form: the
> > tendency to shorten one's code.
> 
> Naah -- if shortening was obsessing you, you'd code the
> finally clause's body as self.ii += 1 ...

+= is unpythonic (it confuses the hell out of new Python programmers,
it's More Than One Way To Do It, it's implicit rather than explicit,
and its raison d'etre is performance optimization, and all this has no
doubt been said before, so I'll stop now) and isn't portable to
pre-2.0 versions of Python, so I don't use it very often.




More information about the Python-list mailing list