Speeding up arXiv browsing
Staying up to date with the newest NLP work is a tough job, and reading about new research takes a significant amount of my time. For several years, one of my work routines has been skimming over the arXiv digest. I open a few preprints, glance over them, and write some notes into Zotero. Once a month, I write a blog post about what I think was the most interesting, which should force me to understand the papers, at least […]
Read moreWhen NumPy is too slow
If you’re doing numeric calculations, NumPy is a lot faster than than plain Python—but sometimes that’s not enough. What should you do when your NumPy-based code is too slow? Your first thought might be parallelism, but that should probably be the last thing you consider. There are many speedups you can do before parallelism becomes helpful, from algorithmic improvements to working around NumPy’s architectural limitations. Let’s see why NumPy can be slow, and then some solutions to help speed up […]
Read moreWhy Are Membership Tests So Fast for range() in Python?
In Python, range() is most commonly used in for loops to iterate over a known range of numbers. But that’s not all it can do! There are other interesting uses of range(). For example, you can pick out elements of a range or check whether a given number belongs to a range of numbers. The latter operation is known as a membership test. Python’s range() objects support most of the operations that you’ve come to expect from lists. For example, […]
Read moreJinja Templating
Templates are an essential ingredient in full-stack web development. With Jinja, you can build rich templates that power the front end of your Python web applications. Jinja is a text templating language. It allows you to process a block of text, insert values from a context dictionary, control how the text flows using conditionals and loops, modify inserted data with filters, and compose different templates together using inheritance and inclusion. In this video course, you’ll learn how to: Install the […]
Read moreHow to Flatten a List of Lists in Python
Sometimes, when you’re working with data, you may have the data as a list of nested lists. A common operation is to flatten this data into a one-dimensional list in Python. Flattening a list involves converting a multidimensional list, such as a matrix, into a one-dimensional list. To better illustrate what it means to flatten a list, say that you have the following matrix of numeric values: >>> >>> matrix = [ … [9, 3, 8, 3], … [4, 5, […]
Read more