On Oct 22, 2007, at 6:32 AM, klaus wrote:
> > Hi all, > I wonder why some classes/objects implement part of a list interface - > but without a __len__ method. Obvious examples are: > > Query has __iter__ and __getitem__, both of which access the database. > __len__ would be a nice alternative to a basic count(). can't put __len__ on query for the reasons simon described. would issue COUNT queries for every list() evaluation (which is basically every query). this is a python limitation that theres no way to force list() to use only __iter__ without calling __len__() first. > > Session has __iter__ and __contains__. __len__ could be used to > indicate when the session gets too large and should be cleared. persistent, non-dirty objects in the session are weakly referenced in 0.4 and will automatically fall out of scope if not referenced elsewhere. that said, theres no reason __len__() couldnt be on Session anyway. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---