Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Filter by Categories
About Article
Analyze Data
Archive
Best Practices
Better Outputs
Blog
Code Optimization
Code Quality
Command Line
Course
Daily tips
Dashboard
Data Analysis & Manipulation
Data Engineer
Data Visualization
DataFrame
Delta Lake
DevOps
DuckDB
Environment Management
Feature Engineer
Git
Jupyter Notebook
LLM
LLM Tools
Machine Learning
Machine Learning & AI
Machine Learning Tools
Manage Data
MLOps
Natural Language Processing
Newsletter Archive
NumPy
Pandas
Polars
PySpark
Python Helpers
Python Tips
Python Utilities
Scrape Data
SQL
Testing
Time Series
Tools
Visualization
Visualization & Reporting
Workflow & Automation
Workflow Automation

Newsletter #310: Slim: Shrink Docker Images by 30x with One Command

Newsletter #310: Slim: Shrink Docker Images by 30x with One Command

Grab your coffee. Here are this week’s highlights.


📅 Today’s Picks

Slim: Shrink Docker Images by 30x with One Command

Code example: Slim: Shrink Docker Images by 30x with One Command

Problem

Docker images include the entire OS layer. For a simple Python app, this is unnecessary because it never touches the shells, compilers, and system utilities bundled inside.

This inflates images to hundreds of megabytes, wasting storage and adding time to every deploy.

Solution

Slim automatically analyzes your container at runtime to identify which files are actually used, then builds a minimal image with only essential components.

Slim works alongside Docker, not instead of it:

  • Step 1: Build your image with docker build
  • Step 2: Minify with slim build your-image
  • Step 3: Push the .slim image to your registry
  • Your Dockerfile and workflow stay the same

Polars: Vectorize List Column Transformations with list.eval

Code example: Polars: Vectorize List Column Transformations with list.eval

Problem

When working with list columns, most people reach for apply with a Python lambda that loops over every list row by row.

That approach breaks vectorization, so performance quickly degrades as the dataset grows.

Solution

Polars solves this with list.eval, which runs a full expression against each list using pl.element() and stays fully vectorized.

Key benefits:

  • Vectorized per-element transformations without Python loops
  • Support for a wide range of expressions, including aggregations like max, mean, and sum
  • Composable with other Polars expressions for clean, readable pipelines

☕️ Weekly Finds

pyupgrade [Code Quality] – A tool (and pre-commit hook) to automatically upgrade syntax for newer versions of Python.

doxx [Python Utils] – Expose the contents of .docx files without leaving your terminal. Fast, safe, and smart, with no Office required.

ingestr [Data Processing] – ingestr is a CLI tool to copy data between any databases with a single command seamlessly.

Looking for a specific tool? Explore 70+ Python tools →

Stay Current with CodeCut

Actionable Python tips, curated for busy data pros. Skim in under 2 minutes, three times a week.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top

Work with Khuyen Tran

Work with Khuyen Tran