launchpad-dev team mailing list archive
-
launchpad-dev team
-
Mailing list archive
-
Message #03993
Re: APIs and len() of collections
On Wed, Jul 28, 2010 at 7:58 PM, Martin Pool <mbp@xxxxxxxxxxxxx> wrote:
> If you accept my theory that API clients want three kinds of semantic
> operation ("count them", "give me all", "give me a few") then it seems
> reasonable to have a specific clear network operation that means
> "count them." It shouldn't be accidentally called as a side effect of
> eg getting or iterating over a list of objects, but it shouldn't
> require you to jump through hoops either: only when the client
> specifically does want to know the number.
This is effectively the approach we're pursuing. We've removed the
cases where a client can inadvertently trigger a potentially expensive
call to len() but left in the ability to explicitly call it if so
desired.
--
Benji York
References