4 messages in com.googlegroups.sqlalchemy[sqlalchemy] Re: Please add some __le...| From | Sent On | Attachments |
|---|---|---|
| klaus | 22 Oct 2007 03:32 | |
| King Simon-NFHD78 | 22 Oct 2007 03:46 | |
| Michael Bayer | 22 Oct 2007 06:37 | |
| klaus | 23 Oct 2007 01:08 |
| Subject: | [sqlalchemy] Re: Please add some __len__ methods![]() |
|---|---|
| From: | klaus (klau...@haufe.de) |
| Date: | 10/23/2007 01:08:49 AM |
| List: | com.googlegroups.sqlalchemy |
Seems like I am learning more python on this list than I ever wanted...
On 22 Okt., 15:37, Michael Bayer <mike...@zzzcomputing.com> wrote:
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 sqla...@googlegroups.com
To unsubscribe from this group, send email to
sqla...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---




