Skip to content

quainy-labs/python-first-principles

Repository files navigation

Python: From First Principles to Professional Engineering

A complete first-principles journey into Python, CPython internals, software engineering, and the Python ecosystem.

Philosophy

This project aims to be the definitive Python curriculum.

The objective is not merely learning syntax.

The objective is mastery.

Every concept answers:

  • What is it?
  • Why does it exist?
  • What problem does it solve?
  • How does it work?
  • How is it implemented?
  • What are the tradeoffs?
  • How does it connect to previous concepts?

The curriculum follows strict dependency order and avoids unexplained magic.


Target Audience

  • Beginners seeking deep understanding.
  • Intermediate developers wanting solid foundations.
  • Professional engineers transitioning into Python.
  • Interview preparation.
  • Open-source contributors.
  • Engineers interested in CPython internals.

Book Structure

Start with the Preface for the curriculum's intent, reading guidance, and expectations.

Volume I — Foundations and Core Language

Volume I builds the complete mental model required before advanced Python feels natural. It starts below Python, moves through execution, objects, references, primitive types, control flow, functions, data structures, memory behavior, and finally modules/imports.

Part I — Foundations of Computing

  1. What Is Software?
  2. Computer Architecture
  3. Processes and Execution
  4. Operating Systems

Part II — Understanding Python

  1. History and Philosophy of Python
  2. Python Implementations
  3. How Python Runs: Source Code to Bytecode
  4. Bytecode and the Python Virtual Machine

Part III — Objects and References

  1. Everything Is an Object
  2. Names and References
  3. Mutability
  4. Identity, Equality, and Memory Diagrams

Part IV — Primitive Types and Expressions

  1. Numbers
  2. Strings
  3. Booleans
  4. Operators
  5. Expressions

Part V — Control Flow

  1. Conditionals
  2. Loops

Part VI — Functions

  1. Functions, Parameters, and Return Values
  2. Scope and Namespaces
  3. Closures
  4. Call Stack and Stack Frames
  5. Recursion
  6. Functional Programming

Part VII — Data Structures

  1. Lists
  2. Tuples
  3. Dictionaries
  4. Sets
  5. Comprehension Patterns
  6. Specialized Collections: deque, Counter, defaultdict, heapq, and bisect
  7. Custom Data Structures

Part VIII — Memory Management

  1. Stack vs Heap
  2. Reference Counting
  3. Garbage Collection
  4. Object Lifecycle
  5. Weak References

Part IX — Modules and Imports

  1. Modules
  2. Packages
  3. Import System
  4. Namespaces
  5. Virtual Environments

Volume II — Advanced Python and Internals

Volume II moves from using Python correctly to understanding Python's advanced protocols, object model, runtime behavior, and implementation mechanics.

Part I — Object-Oriented Python

  1. Classes and Instances
  2. Attributes and Methods
  3. Encapsulation and Managed Attributes
  4. Composition
  5. Inheritance and Method Overriding
  6. MRO and super()
  7. Polymorphism and Duck Typing
  8. ABCs and Mixins
  9. Dataclasses

Part II — The Python Data Model

  1. Dunder Methods
  2. Operator Overloading
  3. Descriptors
  4. Properties, Static Methods, and Class Methods
  5. __slots__
  6. Metaclasses

Part III — Pythonic Abstractions

  1. Iterators
  2. Generators
  3. Context Managers
  4. Decorators

Part IV — Robust Programs and I/O

  1. Exceptions
  2. Files and Serialization
  3. Standard Library Deep Dive

Part V — Concurrency and Parallelism

  1. Concurrency Foundations
  2. Threads, Processes, and the GIL
  3. Asyncio and Event Loops

Part VI — Type System and Internals

  1. Runtime Type System
  2. Bytecode Internals
  3. CPython Architecture
  4. C Extensions

Volume III — Software Engineering

Volume III turns Python knowledge into production engineering practice, including testing, debugging, packaging, modern project tooling, typing, profiling, design, architecture, APIs, and microservices.

  1. Testing
  2. Mocking and Monkey Patching
  3. Debugging
  4. Logging
  5. Packaging
  6. Type Hints
  7. Static Type Checking
  8. Profiling
  9. Design Patterns
  10. SOLID Principles
  11. Architecture
  12. APIs
  13. Microservices

Volume IV — Ecosystem and Career Paths

Volume IV connects Python mastery to real-world domains, frameworks, libraries, modern LLM tooling, model hubs, AI systems, automation, and professional specialization paths.

Part I — Web Development

  1. Flask
  2. Django
  3. FastAPI

Part II — Data and Scientific Computing

  1. NumPy
  2. Pandas
  3. Polars
  4. SciPy

Part III — Machine Learning and AI Engineering

  1. scikit-learn
  2. PyTorch
  3. TensorFlow
  4. AI Engineering
  5. RAG Systems
  6. Agents

Part IV — Automation and Integration

  1. APIs and Automation
  2. Scripting for Real Workflows

Part V — Career Paths

  1. Backend Engineering
  2. Data Engineering
  3. Machine Learning Engineering
  4. AI Engineering
  5. DevOps
  6. Cybersecurity

Capstone Projects

Capstones are placed after the learner has the prerequisites needed to build them properly. They should reinforce the book instead of acting as disconnected exercises.


Goal

After completing this curriculum, the learner should need only:

  • Official documentation.
  • Domain-specific resources.

No general Python tutorial should be necessary.

About

A complete first-principles journey into Python, CPython internals, software engineering, and the Python ecosystem.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors