dict keys are row id...

So you avoid a for to build you list if you use .as_dict() because you can
iterate over it, but I don't think there is any gain in performance since
building dict is expensive. The only gain will be that you code will be
shorter...

Richard




On Tue, Feb 19, 2013 at 4:55 PM, Richard Vézina <ml.richard.vez...@gmail.com
> wrote:

> May be better use .as_ditc() but not sure the id get mapped into dict key
> you have to check, but if the key id is the row id you can iterate directly
> over dict like this :
>
> for id in dict:
> ...
>
>
> On Tue, Feb 19, 2013 at 4:51 PM, Richard Vézina <
> ml.richard.vez...@gmail.com> wrote:
>
>> You can try this and see what you can do with that :
>> db(db.table).select(db.table.id).as_list()
>>
>> By selecting db.table.id you will prevent the overhead of web2py
>> compute=, represent=, etc.
>>
>> Richard
>>
>>
>> On Tue, Feb 19, 2013 at 4:26 PM, <bracq...@gmail.com> wrote:
>>
>>> If I select all items in a database:
>>>
>>> rows = db(db.table).select()
>>>
>>> I can get the ids by doing something like:
>>>
>>> ids = []
>>> for row in rows:
>>>     ids.append(row.id)
>>>
>>> However, is there a better way to get the ids straight from the rows
>>> variable (without executing raw sql)? I feel like I'm iterating through the
>>> entire list of items twice by doing this.
>>>
>>> --
>>>
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "web2py-users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to web2py+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>
>>
>>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to