Welcome
This is my personal notepad mostly about Python, SQL, GitHub and stuff.
Recent Posts
Positional-only and keyword-only parameters
An overview of some neat peculiarities of the positional-only and keyword-only parameters in Python.
Counting in SQLAlchemy
Basic ways to count rows of a SQL table in SQLAlchemy using the standard
count
function.Not All itertools Are Lazy
Simple demonstration that itertools.product does not retrieve elements from the input iterables lazily, i.e. only when the next element is needed. Rather, the
product
object will read all values immediately upon its construction.Nullable and Non-nullable Columns in SQLAlchemy 2
Two basic ways to declare the nullable property of a table column in SQLAlchemy 2.0 ORM.
Notes on Pattern Matching of Dictionaries
Two peculiarities worth knowing about pattern matching of Python dicts.
Recursive Generator Example: Prime Factors
Python’s generators with their
yield
andyield from
statements allow for elegant and terse (and lazy) solutions to recursive problems.Storing Reference to Save Method Look-up
This is a simple timing experiment to explore whether it is possible in Python to gain performance benefit by calling a method via a direct reference instead of accessing it as an object’s attribute.
Extending pathlib.Path in Python
Demonstration of the gotcha associated with subclassing the
pathlib.Path
class from Python’s standard library.Regex Named Groups in Python
A quick refresher on the syntax of named groups (also known as named subpatterns) in regular expressions.
Importing Python Code from URL
A rather silly experiment.
Class Properties in Python
As of Python version 3.9, it is possible to define a class property (i.e. a computed or otherwise managed class attribute) by simply stacking the
classmethod
andproperty
decorators.LBYL vs EAFP Timing Comparison
A simple experiment in Python comparing performance of two approaches to solve the same problem.
Joining Sequences in Python
The numerous ways Python offers to concatenate sequences such as lists, strings, byte arrays etc.