map() vs. List Comprehension
Is the map() function faster than a corresponding list comprehension? That depends! Let's see how using lambda functions can affect the performance of map().
Is the map() function faster than a corresponding list comprehension? That depends! Let's see how using lambda functions can affect the performance of map().
Running one big blob of code is often faster than splitting your code into well-separated functions. But there are other ways you can improve the speed of your code without sacrificing its readability.
pathlib is an interesting, object-oriented take on the filesystem paths. With plenty of functions to create, delete, move, rename, read, write, find, or split files, pathlib is an excellent replacement for the os module. But is it faster?
With four different ways of formatting strings in Python 3.6 and above, it's time to look at which one is the fastest.
What's the best way to compare something to None in Python?
Is using dictionary comprehension faster than calling the dict() function? And what's the most efficient way to create a dictionary from two iterables?
Is using {} faster than dict()? If yes, then why? And when would you use one version over the other?
There are plenty of ways to measure the speed of your code. Let me show you a few that I considered for the Writing Faster Python series.
Can we speed up our code examples by simply upgrading the Python version? And if yes, by how much?
pyenv is a tool that lets you easily install new Python versions and switch between them.
I don't always do the Advent of Code challenges. But when I do, I do them in IPython. Let me show you why.
What's the fastest way to remove duplicates from a list?
What's the difference between type() and isinstance() methods, and which one is better for checking the type of an object?
Why iterating over the whole list is a bad idea, what data structure is best for membership testing, and when it makes sense to use it?
How can we compare a variable to True or False, what's the difference between "is" and "==" operators, and what are truthy values?
What's the fastest way to sort a list? When can you use sort() and when you need to use sorted() instead?
Simple "for loops" can be replaced with a list comprehension. But is it going to make our code faster? And what limitations list comprehension has?
Dictionaries in the latest Python versions preserve the insertion order. So, is there any reason to use the OrderedDict as we used to do in the past?
Numba library has plenty of tools to speed up your mathematical-heavy programs. From a simple @jit decorator, all the way to running your code on a CUDA GPU.
How to quickly find something in a collection of items, like a list or a range? When a generator expression is a great solution, and when it's not?
Is it faster to "ask for forgiveness" or "look before you leap" in Python? And when it's better to use one over the other?
Introduction to the "Writing Faster Python" series. What it is about, how do I benchmark, frequently asked questions, and additional resources.
List of my favorite VS Code plugins that helps me build Python application.
Tips and tricks on how to use IPython as your debugger.
How to stop pip from running outside of a virtual environment and messing up your dependencies?
Python 3 is great! But not every Python 2 project has to be migrated. There are different ways how you can prepare for the upcoming Python 2 End of Life.
What are IPython extensions, how to install them, and how to write and publish your own extension?
Tired of having to reload a module each time you change it? %autoreload to the rescue!
Slides for my talk "It's 2019 and I'm still using Python 2. Should I be worried?"
Slides for my talk "Wait, IPython can do that?!"
In this last part of the magic functions series, we will create a Magics class.
Continue the magic functions journey and create a cell magic function that checks type hints in IPython.
Learn how to make your own magic functions in IPython by creating a line magic function.
How to easily remember the difference between __str__ and __repr__ functions in Python?
How you can automatically run Python scripts when starting IPython and why this can be useful?