On Aug 14, 2007, at 4:35 PM, Michael Bayer wrote:
> On Aug 14, 2007, at 12:38 PM, svilen wrote: >> >> >> ------- >> orm.attribute >> AttributeManager.init_attr(): >> the saving this one eventualy does is too small, compared to a >> property call of ._state. > > i havent benched this in a while but my recollection is that the > AttributeError raise is *much* slower than pre-calling this method. > a single function call is always faster than an exception throw. > > however, i see that the exception throw is being suppressed also with > a hasattr() being called every time....im not sure why thats that way > now so i might change it back to throwing AttributeError. the results are in, running test/prof/masseagerload.py. this test is very heavy on creating new instances from mapper rows, which is where the initialization of _state comes in. no init_attr(), detect missing with AttributeError Profiled target 'masseagerload', wall time: 0.59 seconds Profile report for target 'masseagerload' (masseagerload.prof) 57039 function calls (55962 primitive calls) in 0.489 CPU seconds init_attr(), detect missing with AttributeError Profiled target 'masseagerload', wall time: 0.53 seconds 57549 function calls (56472 primitive calls) in 0.426 CPU seconds init_attr(), detect missing with hasattr Profiled target 'masseagerload', wall time: 0.56 seconds 57549 function calls (56472 primitive calls) in 0.431 CPU seconds no init_attr(), detect missing with hasattr Profiled target 'masseagerload', wall time: 0.49 seconds 57039 function calls (55962 primitive calls) in 0.390 CPU seconds im not exactly sure why the "hasattr()" call, being present and then removed, doesnt change the number of function calls. anyway, the times vary a little bit but the "hasattr" call, even though its called many more times than the AttributeError gets raised, is slightly faster than raising AttributeError. so no AttributeError, and I like getting rid of init_attr() very much so its out in r3313. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---