Skip to main content Brad's PyNotes

Posts

2025

  1. Multiprocessing Module

    TL;DR

    The multiprocessing module creates separate Python processes that bypass the GIL, enabling true parallel execution for CPU-intensive tasks.

    Interesting!

    Unlike threading, multiprocessing actually uses multiple CPU cores simultaneously - each process has its own Python interpreter and memory space!

  2. Zipfile Module

    TL;DR

    The zipfile module provides tools for creating, reading, and extracting ZIP archives with support for multiple compression methods and password protection.

    Interesting!

    The module supports ZIP64 extensions, allowing you to work with ZIP files larger than 4GB and containing more than 65,535 files - breaking traditional ZIP format limits!

  3. What Now Tutorial

    TL;DR

    After learning Python basics, dive into the Standard Library, explore PyPI packages, join the community, and tackle real-world projects.

    Interesting!

    Python has one of the most comprehensive standard libraries of any programming language - so much functionality is available without installing anything extra!

  4. String Module

    TL;DR

    The string module provides string constants, Template class for simple substitution, and advanced formatting utilities for text processing.

    Interesting!

    The string.Template class provides a safer alternative to % formatting - it prevents code injection by not allowing arbitrary expressions!

  5. Stdlib Tour 2 Tutorial

    TL;DR

    The second stdlib tour covers professional-grade modules: precise decimal arithmetic, efficient data structures, logging, threading, and binary data handling.

    Interesting!

    The decimal module can represent exact monetary values without floating-point errors - crucial for financial applications where precision matters!

  6. Pickle Module

    TL;DR

    The pickle module serializes Python objects to bytes and deserializes them back - enabling object persistence and inter-process communication.

    Interesting!

    Pickle can serialize almost any Python object, including functions, classes, and nested objects - but never unpickle untrusted data as it can execute arbitrary code!

  7. PEP 622 Pattern Matching

    TL;DR

    PEP 622 introduced match-case statements for structural pattern matching, enabling elegant destructuring and dispatch based on data shape and values.

    Interesting!

    Pattern matching brings functional programming elegance to Python - you can destructure complex nested data in a single line and handle different cases cleanly!

  8. PEP 3107 Function Annotations

    TL;DR

    PEP 3107 introduced syntax for adding metadata to function parameters and return values, stored in __annotations__ - the foundation for modern type hints.

  9. Glob Module: Unix-Style Pathname Pattern Matching

    TL;DR

    The glob module finds all pathnames matching a Unix shell-style pattern using wildcards like * (any characters), ? (single character), and [seq] (character ranges), making file discovery and batch operations simple.

  10. Appetite Tutorial

    TL;DR

    Python excels at automation and rapid development with its simple syntax, powerful features, and “batteries included” philosophy - perfect for getting things done quickly.

  11. Venv Tutorial

    TL;DR

    Virtual environments create isolated Python installations to prevent package conflicts between projects using python -m venv.

    Interesting!

    Virtual environments solve the “dependency hell” problem - you can have different versions of the same library for different projects without conflicts!

  12. Threading Module

    TL;DR

    The threading module enables concurrent execution through threads with synchronization primitives like Lock, Event, and Semaphore for safe resource sharing.

    Interesting!

    Python’s Global Interpreter Lock (GIL) means only one thread executes Python code at once - threading helps with I/O-bound tasks, not CPU-bound ones!

  13. Sqlite3 Module

    TL;DR

    The sqlite3 module provides a lightweight, disk-based database interface that supports SQL queries without requiring a separate server process.

    Interesting!

    SQLite is the most widely deployed database engine in the world - it’s built into every smartphone, browser, and operating system!

  14. PEP 585 Generics

    TL;DR

    PEP 585 made built-in collections generic, allowing list[int] instead of List[int] - eliminating duplicate type hierarchies in the typing module.

    Interesting!

    Before PEP 585, Python had two separate type systems - one for runtime and one for type hints. Now built-in collections work for both!

  15. Heapq Module: Efficient Priority Queue Operations

    TL;DR

    The heapq module provides heap queue (priority queue) operations using a binary heap implemented as a list, where heappush() and heappop() maintain the heap invariant with O(log n) complexity.

  16. Stdlib Tour Tutorial

    TL;DR

    Python’s standard library provides essential modules for OS operations, file handling, math, networking, dates, and performance measurement - “batteries included”!

    Interesting!

    Python’s standard library is so comprehensive that many tasks don’t require external dependencies - from web requests to compression, it’s all built-in!

  17. Statistics Module

    TL;DR

    The statistics module provides mathematical statistics functions for calculating averages, spread measures, and correlations without external dependencies.

    Interesting!

    Unlike floating-point calculations, the statistics module can work with Decimal and Fraction types for exact mathematical precision in statistical calculations!