New
High Performance Python
Practical Performant Programming for Humans
by Ian Ozsvald, Micha Gorelick
Pages
217
Published
2020
Write Concise, Expressive Programs Using a Single Line of Python
Master idiomatic Python by learning to pack real logic, data transformations, and algorithms into single, readable lines of code.
Python One-Liners teaches you to write compact, expressive programs by solving real problems in a single line of code. Author Christian Mayer walks through five domains — data science, machine learning, regular expressions, algorithms, and more — showing how Python's built-in features combine into elegant solutions. Each one-liner is dissected line by line so you understand not just what it does, but why it works. By the end, you'll read and write idiomatic Python with noticeably more confidence.
Most Python tutorials teach you syntax. This book teaches you fluency. There is a gap between knowing Python's keywords and knowing how to combine them the way experienced practitioners do. Python One-Liners closes that gap by forcing a constraint: solve the problem in a single line.
The constraint is not a gimmick. When you compress a solution to one line, you have to understand slicing, list comprehensions, lambda functions, generator expressions, and the standard library well enough to reach for them instinctively. Working through each one-liner builds that muscle memory in a way that reading reference docs never does.
Author Christian Mayer, creator of the Finxter Python learning platform, selects one-liners across five practical domains: data science with NumPy and pandas, machine learning with scikit-learn, regular expressions for text processing, algorithmic puzzles, and general Python idioms. Each entry follows the same structure: you see the one-liner, you see it broken into readable multi-line code, and then you read a plain-English explanation of every moving part.
By the time you finish, you will have encountered:
The book is 217 pages, which means every page earns its place. There is no filler. You can read it cover to cover in a weekend, or keep it beside your editor and dip in when you want a sharper way to express something you already know how to do the long way.
If you write Python regularly and want to stop reaching for stack overflow every time you need a clean one-pass solution, this is the book that changes how you see the language.
Reviews the core Python features that make one-liners possible: list comprehensions, slicing, lambda functions, and key built-ins. Establishes the vocabulary you will use for the rest of the book.
Introduces the fundamental one-liner techniques — chained comparisons, ternary expressions, and string manipulation shortcuts — through a series of progressively more useful examples.
Applies one-liner thinking to real data-wrangling tasks using NumPy and pandas, showing how broadcasting, vectorised operations, and method chaining replace verbose imperative loops.
Condenses core machine learning workflows — training, predicting, and evaluating models with scikit-learn — into single lines that expose the essential logic of each step.
Builds practical regex one-liners for extracting, validating, and transforming text, with each pattern dissected so you understand what every character contributes.
Solves classic algorithmic problems — searching, sorting, and graph traversal — in a single line, revealing how Python's standard library and built-ins do the heavy lifting.
Demonstrates one-liners for reading, transforming, and writing multimedia data using Python libraries, showing how a single expression can encode a complete processing pipeline.
Yes. The book assumes you are comfortable with Python basics: variables, loops, functions, and standard data structures. A brief refresher chapter covers the features used most heavily, but this is not a beginner introduction to the language.
Each one-liner is dissected into its multi-line equivalent with a plain-English explanation. The goal is to build genuine understanding of Python idioms — list comprehensions, higher-order functions, slicing — that you apply in everyday code, not just party tricks.
Yes. All code in the book is written for Python 3. A few examples use libraries such as NumPy, pandas, and scikit-learn, which are all current Python 3 packages.
The book includes all one-liners printed in full. For any supplementary resources, check the publisher's page at No Starch Press, where companion files are listed when available.
It is a strong fit if you already write Python and want cleaner, more expressive data manipulation. Dedicated chapters on NumPy, pandas, and scikit-learn one-liners address common data science workflows directly.
New
Practical Performant Programming for Humans
by Ian Ozsvald, Micha Gorelick
New
A thorough reference to Python language fundamentals, from syntax and data types to classes and advanced tools
by Mark Lutz
New
A Hands-On, Project-Based Introduction to Programming in Python
by Eric Matthes
New
A Concise Desktop Reference for Python 3 — Language, Libraries, and Best Practices
by Alex Martelli, Anna Martelli Ravenscroft, Paul McGuire, Steve Holden