Skip to main content

111 docs tagged with "python-advanced"

View all tags

__set_name__ - The Descriptor Naming Protocol

Understand __set_name__, Python's descriptor self-naming protocol - how it eliminates name redundancy, how type.__new__ calls it, and how Django, Pydantic, and SQLAlchemy use it to build self-configuring field systems.

Advanced Event Loop

Master event loop internals including selectors, callbacks, timers, custom policies, uvloop, run_in_executor, and signal handling for production async systems.

Advanced Generic Patterns

Master Self type, TypeVarTuple, recursive types, generic protocols, and generic type aliases for framework-level type-safe design including builder patterns and tensor shape typing.

Async Context Managers

Master async resource management with __aenter__/__aexit__, asynccontextmanager, AsyncExitStack, and production patterns for connection pools and sessions.

Async Generators and Async Iterators

Build streaming data pipelines with async for, async yield, __aiter__/__anext__, async comprehensions, and finalization protocols for production async iteration.

Async Synchronization Patterns

Implement bounded concurrency, rate limiting, and circuit breakers with asyncio locks, semaphores, events, conditions, and barriers.

Bottleneck Optimizer

Take a deliberately slow codebase and systematically optimize it using profiling.

Build a Web Framework

Minimal ASGI framework with routing, middleware, dependency injection, and metaclass-based route registration.

Capstone Overview

Five production-grade capstone projects that integrate metaprogramming, advanced typing, async patterns, performance engineering, architecture, and security.

cProfile and pstats - Function-Level Profiling

Master deterministic profiling with cProfile and pstats - reading profile output, sorting and filtering results, snakeviz visualization, profiling overhead, and real-world endpoint profiling.

Cryptographic Hashing

Master data hashing vs password hashing - hashlib, bcrypt, argon2, salting, timing attacks, constant-time comparison, and why MD5/SHA1 are broken for passwords.

Custom Awaitables

Build awaitable objects with the __await__ protocol, understand how coroutines and Futures work under the hood, and create custom async primitives.

Custom ORM Core

Build a mini SQLAlchemy-style ORM using metaclasses, descriptors, and __set_name__ to map Python classes to database tables.

Generics and TypeVar

Master generic programming in Python with TypeVar, Generic base class, bound and constrained type variables, covariance vs contravariance vs invariance, and real-world patterns from FastAPI and SQLAlchemy.

Input Validation and Sanitization

Use Pydantic validators as security boundaries - prevent SQL injection, XSS, path traversal, SSRF, and file upload attacks through structural input validation in FastAPI.

JWT Authentication

Master stateless JWT authentication - token structure, signing algorithms, refresh token rotation, common pitfalls, and building production-grade FastAPI JWT middleware.

Memory Optimization - Fitting More in Less

Reduce Python memory usage with __slots__, weakref, array module, struct.pack, memory-mapped files, object pooling, and the flyweight pattern for processing millions of records.

Metaclasses - The Class of Classes

Understand type as the metaclass of all classes, the full class creation pipeline, __new__, __init__, __call__ on metaclasses, __prepare__, metaclass inheritance and conflicts, and real-world usage in Django, SQLAlchemy, and ABC.

Modular Plugin System

Build an extensible CLI tool with plugin discovery, loading, and lifecycle management.

Module 01 - Metaprogramming Overview

Master the machinery that powers every serious Python framework - metaclasses, descriptors, __init_subclass__, __set_name__, dynamic class creation, and import hooks. Write code that writes code.

Module 02: Advanced Type System - Complete Overview

Master Python's type system at production depth - generics, Protocol, TypeVar, ParamSpec, overload, runtime checking, and static analysis with mypy and pyright. The module that turns type hints from annotations into engineering infrastructure.

Module 04 - Performance Engineering Overview

Master Python performance from measurement to optimization - profiling strategy, caching, memory optimization, vectorization, and C extensions for building high-throughput systems.

Module 06 - Security Engineering

Master security engineering in Python - cryptographic hashing, JWT authentication, OAuth 2.0, input validation, SQL injection prevention, secrets management, and secure coding patterns that protect production systems from real-world attacks.

OAuth 2.0 and OIDC

Implement OAuth 2.0 authorization code flow with PKCE, OpenID Connect ID tokens, Keycloak integration, and delegated authorization in FastAPI with authlib.

Overload and Type Narrowing

Use @overload for multiple function signatures and TypeGuard, TypeIs, assert_never, and pattern matching for exhaustive type narrowing in Python.

ParamSpec and Concatenate

Solve the decorator typing problem with ParamSpec and Concatenate -- preserve callable signatures through wrappers, type retry/logging decorators, and apply patterns from FastAPI middleware.

Plugin Framework

Build an auto-discovering plugin system using __init_subclass__, class registries, and import hooks.

Production Async Architecture

Build production-grade async systems with error handling strategies, graceful shutdown, health checks, backpressure, async testing with pytest-asyncio, and structured logging.

Protocol and Structural Subtyping

Master typing.Protocol for structural subtyping in Python -- define interfaces based on behavior, compose protocols, make duck typing type-safe, and apply patterns from Django and file-like objects.

Runtime Type Checking

Validate data at system boundaries using get_type_hints, isinstance limitations, beartype, typeguard, and Pydantic's runtime validation model, and build a custom runtime validator.

Secrets Management

Manage secrets securely with python-dotenv, Pydantic SecretStr, AWS Secrets Manager, HashiCorp Vault, git-secrets, and production credential rotation strategies.

Secure Coding Patterns

Apply defense in depth, least privilege, CORS, rate limiting, CSP headers, dependency auditing with pip-audit, and static analysis with bandit to harden FastAPI applications.

Security Audit Tool

Build a CLI tool that scans Python projects for common security vulnerabilities.

SQL Injection Prevention

Prevent SQL injection through parameterized queries, SQLAlchemy best practices, ORM safety limits, raw SQL auditing, and defense against UNION, blind, and second-order injection.

Static Analysis in Practice

Configure mypy and pyright for strict mode, gradual typing adoption, type stubs, py.typed markers, CI integration, and strategies for migrating untyped codebases.

Structured Concurrency with TaskGroup

Master asyncio.TaskGroup for safe concurrent execution, understand why gather() leaks tasks, handle ExceptionGroups, and implement the nursery pattern.