A search can be inefficient if we examine all of the objects in a database, and apply a filter. We'd prefer to work with a more focused subset of items. We'll look at how we can create more useful indices in the Creating indexes to improve efficiency section. The fallback plan of brute-force scanning all the objects, however, always works. For searches that occur rarely, the computation required to create a more efficient index may not be worth the time saved.
Don't panic; searching, scanning, and querying are synonyms. We'll use the terms interchangeably.
When a child class has an independent-style key, we can scan a shelf for all instances of some Child class using an iterator over the keys. Here's a generator expression that locates all the children:
children = (shelf[k]
for k in shelf.keys()
if k.startswith...