View Single Post
Old 08-05-2013, 03:25 PM   #149
JimmXinu
Plugin Developer
JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.
 
JimmXinu's Avatar
 
Posts: 7,045
Karma: 4604637
Join Date: Dec 2011
Location: Midwest USA
Device: Kobo Clara Colour running KOReader
Quote:
Originally Posted by kovidgoyal View Post
You should not need to do anything at all. It may happen that some operations, typically updating a field in the database for many books, one at a time, becomes slower, in which case you should re-write it to use the new api. Other than that, you should not need to do anything, and that only if you or your users notice some slowness. Basically, where you had:

Code:
for book_id in book_ids:
   db.set_something(book_id, value)
replace it with

Code:
db.new_api.set_field(something, {book_id:value for book_id in book_ids})
Is this example the only recommended refactoring for plugins found so far?

Will it now be safe for PIs to skip self.gui.proceed_question() when updating the DB? (When using new DB, of course.)

Speaking of which, what's the best way for PIs to detect when the new DB is active?

Finally, a suggestion: I would change the name db.new_api (or make an alias for it) that doesn't have 'new' in it. db.api2 maybe. I can tell you from experience that having the word 'new' in your code after it's become old confuses people.
Someday :
"So new_api is the new API?"
"No, new_api is the old API. api3 is the new API."
JimmXinu is offline   Reply With Quote