Changes between Version 40 and Version 41 of DeveloperGuidelines/Optimisation
- Timestamp:
- 06/18/10 08:47:22 (15 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
DeveloperGuidelines/Optimisation
v40 v41 143 143 {{{ 144 144 for id in ids: 145 my_record = db( mytable.id == id).select().first()145 my_record = db(db.mytable.id == id).select().first() 146 146 ... 147 147 }}} … … 149 149 (much) better: 150 150 {{{ 151 records = db( mytable.id.belongs(ids)).select()151 records = db(db.mytable.id.belongs(ids)).select() 152 152 for record in records: 153 153 ... 154 }}} 155 156 It could be hidden...: 157 158 {{{ 159 for x in y 160 id = some_function(x) 161 if id: 162 record = db(db.mytable.id == id).select() 163 }}} 164 165 better: 166 167 {{{ 168 ids = filter(lambda x: some_function(x), y) 169 records = db(db.mytable.id.belongs(ids)).select() 154 170 }}} 155 171 … … 159 175 DeveloperGuidelines 160 176 DeveloperGuidelines 177 DeveloperGuidelines