Book skill speedup
In current skill version, function entity_to_label is executed many times even if books are already chosen - untill we got to the end of the list. That slows skill down.
@@ -439,8 +439,8 @@ def best_plain_book_by_author(plain_author_name, default_phrase, plain_last_book
filtered_bookname_list = []
for book in sorted_bookname_list:
logger.debug(f'{last_bookname.lower()} {entity_to_label(book).lower()}')
- if all([last_bookname.lower() not in entity_to_label(book).lower(),
- len(filtered_bookname_list) < top_n_best_books]):
+ if len(filtered_bookname_list) < top_n_best_books:
+ if last_bookname.lower() not in entity_to_label(book).lower():
filtered_bookname_list.append(book)
if len(sorted_bookname_list) > 0:
best_bookname = random.choice(filtered_bookname_list)
