Jul
7
Creating a new sequence type is easy
Python has a whole hierarchy of collection-related abstract types, described in the collections.abc module in the standard library. But there are two key, prototypical kinds. Iterators are one-shot, used for a single forward traversal, and usually lazy, generating each value on the fly as requested.
2Going faster with NumPy
There are a lot of novice questions on optimizing NumPy code on StackOverflow, that make a lot of the same mistakes. I'll try to cover them all here.
What does NumPy speed up?
Let's look at some Python code that does some computation element-wise on two lists of lists.