[Python-Dev] 2.5a2 try/except slow-down: Convert to type?

Michael Hudson mwh at python.net
Wed May 24 12:36:52 CEST 2006


Sean Reifschneider <jafo-python-dev at tummy.com> writes:

> We're working at the sprint on tracking this down.  I want to provide some
> history first and then what we're looking for feedback on.
>
> Steve Holden found this on Sunday, the pybench try/except test shows a ~60%
> slowdown from 2.4.3 to 2.5a2.  The original test is, roughly:
>
>    for i in range(N):
>       try: raise ValueError, 'something'
>       except: pass
>
> But changing it to the following shows 0% slowdown from 2.4.3 to 2.5a2:
>
>    e = ValueError('something')
>    for i in range(N):
>       try: raise e
>       except: pass
>
> The change is that from 2.4.3 to 2.5a2 includes Brett Cannon's patch to make
> exceptions all new-style objects.

Could it just be that instantiating instances of new-style classes is
slower than instantiating instances of old-style classes?  There's not
anything in what you've posted to suggest that exceptions are involved
directly.

Cheers,
mwh

-- 
  Get out your salt shakers folks, this one's going to take more
  than one grain.                 -- Ator in an Ars Technica news item


More information about the Python-Dev mailing list