Skip to content

Instantly share code, notes, and snippets.

@a-poor
Created August 7, 2020 01:21
Show Gist options
  • Save a-poor/09dc8ad458451a61c5089156e76f728b to your computer and use it in GitHub Desktop.
Save a-poor/09dc8ad458451a61c5089156e76f728b to your computer and use it in GitHub Desktop.
Filename: script.py
Line # Mem usage Increment Line Contents
================================================
19 38.426 MiB 38.426 MiB @profile
20 def read_books(urls):
21 """For each url in urls,
22 load the book and count the words"""
23 # Create a place to store word counts
24 38.426 MiB 0.000 MiB word_counts = {}
25 # For each book: load it, count words, store the counts
26 85.438 MiB 0.000 MiB for title, path in urls.items():
27 72.137 MiB 9.281 MiB book = get_book(path)
28 95.852 MiB 23.715 MiB words = split_words(book)
29 85.438 MiB 0.496 MiB counts = count_words(words)
30 85.438 MiB 0.254 MiB word_counts[title] = counts.most_common()[:10]
31 85.438 MiB 0.000 MiB return word_counts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment