Changes between Version 40 and Version 41 of DeveloperGuidelines/Optimisation


Ignore:
Timestamp:
06/18/10 08:47:22 (11 years ago)
Author:
Dominic König
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DeveloperGuidelines/Optimisation

    v40 v41  
    143143{{{
    144144for id in ids:
    145    my_record = db(mytable.id == id).select().first()
     145   my_record = db(db.mytable.id == id).select().first()
    146146   ...
    147147}}}
     
    149149(much) better:
    150150{{{
    151 records = db(mytable.id.belongs(ids)).select()
     151records = db(db.mytable.id.belongs(ids)).select()
    152152for record in records:
    153153   ...
     154}}}
     155
     156It could be hidden...:
     157
     158{{{
     159for x in y
     160  id = some_function(x)
     161  if id:
     162    record = db(db.mytable.id == id).select()
     163}}}
     164
     165better:
     166
     167{{{
     168ids = filter(lambda x: some_function(x), y)
     169records = db(db.mytable.id.belongs(ids)).select()
    154170}}}
    155171
     
    159175DeveloperGuidelines
    160176DeveloperGuidelines
     177DeveloperGuidelines