View Single Post
Old 02-19-2011, 01:54 PM   #6
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by meme View Post
Its looking good from testing. Why do you use defaultdict instead of just dict?
It is a convenience to avoid the need to test for existence of the key before adding to the set. If there is no item indexed by the key, then defaultdict creates one for you.

If you use a normal dict, then you must do something like:
Code:
  db_id_map = {}
  for blist in matching: # blist == list of (row,book) tuples for the mem location
    for book in blist:
      if book.application_id not in db_id_map: # defaultdict eliminates these 2 lines
        db_id_map[book.application_id] = set([])
      db_id_map[book.application_id].add(book)
Quote:
I have to test using the library_view versus the memory view for columns, etc - if a new column is created I'm not sure if the device view will have the most current list of columns for books.
The device_view databases are copies of the information in metadata.calibre. They will not contain updated metadata. You should use the library_view for all metadata except lpath and path and, if you use it, device_collections.
chaley is offline   Reply With Quote