Re: [sqlalchemy] try: except KeyError:

2012-01-27 Thread Michael Bayer
that was likely for performance yes.


On Jan 25, 2012, at 5:04 PM, Kent wrote:

 At some point you changed the InstrumentedAttribute.get() method from
 
 try:
  return dict_[self.key]
 except KeyError:
 ...
 
 
 To this:
 
 
 432  - def get(self, state, dict_, passive=PASSIVE_OFF):
 433 Retrieve a value from the given object.
 434
 435 If a callable is assembled on this object's attribute,
 and
 436 passive is False, the callable will be executed and
 the
 437 resulting value will be set as the new value for this
 attribute.
 (Pdb)
 438 
 439 if self.key in dict_:
 440 return dict_[self.key]
 441 else:
 442 # if history present, don't load
 443 key = self.key
 444 if key not in state.committed_state or \
 445 state.committed_state[key] is NEVER_SET:
 
 
 I'm extremely interested if this was related to performance or just
 style?
 
 -- 
 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 
 sqlalchemy+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/sqlalchemy?hl=en.
 

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] try: except KeyError:

2012-01-25 Thread Kent
At some point you changed the InstrumentedAttribute.get() method from

try:
  return dict_[self.key]
except KeyError:
 ...


To this:


432  - def get(self, state, dict_, passive=PASSIVE_OFF):
433 Retrieve a value from the given object.
434
435 If a callable is assembled on this object's attribute,
and
436 passive is False, the callable will be executed and
the
437 resulting value will be set as the new value for this
attribute.
(Pdb)
438 
439 if self.key in dict_:
440 return dict_[self.key]
441 else:
442 # if history present, don't load
443 key = self.key
444 if key not in state.committed_state or \
445 state.committed_state[key] is NEVER_SET:


I'm extremely interested if this was related to performance or just
style?

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.