Started: January 2025
Status: Active Development
Purpose: Educational Mastery
I began this project after realizing most Python resources fall into two extremes: oversimplified tutorials that don't scale, or production code too complex for learning. This repository bridges that gap with real, working code that demonstrates exactly how concepts perform in practice.
I use this space to improve upon previous projects, and to create interactive visualizations that make complex concepts intuitive. When I claim asyncio handles 10,000 connections efficiently, I prove it with benchmarks you can reproduce.
%%{init: {'theme':'base', 'themeVariables': { 'primaryColor':'#FFE4E1', 'primaryBorderColor':'#8B7D8B', 'primaryTextColor':'#4A4A4A', 'lineColor':'#DDA0DD', 'secondaryColor':'#E6E6FA', 'tertiaryColor':'#F0F8FF', 'background':'#FFFFFF', 'mainBkg':'#FFE4E1', 'secondBkg':'#E6E6FA', 'tertiaryBkg':'#F0F8FF', 'fontFamily':'Georgia, serif', 'fontSize':'16px'}}}%%
flowchart TB
subgraph Foundation ["Foundation Layer"]
direction LR
A[Environment<br/>Setup] --> B[Package<br/>Management]
B --> C[CLI<br/>Development]
end
subgraph Core ["Core Skills"]
direction LR
D[DateTime<br/>Handling] --> E[Text<br/>Processing]
E --> F[NLP<br/>Basics]
F --> G[HTTP &<br/>APIs]
G --> H[Database<br/>Systems]
end
subgraph Performance ["Performance Layer"]
direction LR
I[Async/<br/>Parallel] --> J[Media<br/>Processing]
J --> K[System<br/>Optimization]
end
subgraph DataScience ["Data Science"]
direction LR
L[Numerical<br/>Computing] --> M[Data<br/>Visualization]
M --> N[Machine<br/>Learning]
end
subgraph Web ["Web Systems"]
direction LR
O[Web<br/>Frameworks] --> P[Authentication<br/>& Security]
P --> Q[Task<br/>Queues]
Q --> R[Data<br/>Validation]
end
subgraph Advanced ["Advanced Topics"]
direction LR
S[System<br/>Architecture] --> T[Desktop<br/>Applications]
T --> U[Algorithms<br/>& DS]
U --> V[Dev<br/>Tools]
end
Foundation --> Core
Core --> Performance
Core --> DataScience
Core --> Web
Performance --> Advanced
DataScience --> Advanced
Web --> Advanced
style Foundation fill:#FFE4E1,stroke:#8B7D8B,stroke-width:3px
style Core fill:#EDE5FF,stroke:#8B7D8B,stroke-width:3px
style Performance fill:#F0E6FF,stroke:#8B7D8B,stroke-width:3px
style DataScience fill:#FFF0F5,stroke:#8B7D8B,stroke-width:3px
style Web fill:#FFEFD5,stroke:#8B7D8B,stroke-width:3px
style Advanced fill:#F5DEB3,stroke:#8B7D8B,stroke-width:3px
MacBook Pro M1 Max, 32GB RAM, Python 3.11.7
I/O-Bound Operations (1000 tasks @ 100ms latency) | |||||
---|---|---|---|---|---|
Method | Execution Time | Memory Usage | CPU Usage | Throughput | Efficiency Score |
Serial Loop | 100.32s | 45 MB | 2% | 10 req/s | βββββ |
Threading (10) | 10.15s | 85 MB | 8% | 98 req/s | βββββ |
Threading (50) | 2.08s | 125 MB | 15% | 481 req/s | βββββ |
AsyncIO + aiohttp | 1.27s | 62 MB | 5% | 787 req/s | βββββ |
CPU-Bound Operations (8 matrix multiplications, 500x500) | |||||
---|---|---|---|---|---|
Method | Execution Time | Memory Usage | CPU Usage | Speedup | Parallel Efficiency |
Serial Loop | 8.14s | 120 MB | 100% (1 core) | 1.0x | 100% |
Threading | 8.09s | 135 MB | 100% (1 core) | 1.0x | 0% (GIL) |
Multiprocessing (4) | 2.31s | 480 MB | 380% | 3.5x | 88% |
NumPy Vectorized | 0.42s | 125 MB | 100% | 19.4x | N/A |
Numba JIT | 0.38s | 130 MB | 100% | 21.4x | N/A |
The concurrency explorer that makes async vs threading performance visible in real-time
Task Timeline
Visualize parallel execution |
Memory Profiler
Track resource usage |
Performance Heatmap
Find bottlenecks instantly |
Live Benchmarks
Compare approaches |
Phase I: Foundation Layer (Click to expand)
Phase II: Core Skills (Click to expand)
Phase III: Data Science & ML (Click to expand)
Phase IV: Web Development (Click to expand)
Phase V: Quality & Performance (Click to expand)
Phase VI: Advanced Topics (Click to expand)
# Clone the repository
git clone https://github.com/Cazzy-Aporbo/velvet-python.git
cd velvet-python
# Create and activate virtual environment
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
# Install development dependencies
pip install -U pip wheel setuptools
pip install -r requirements-dev.txt
# Navigate to any module
cd 09-concurrency
# Install module dependencies
pip install -r requirements.txt
# Run examples
python examples/basic.py
python examples/intermediate.py
python examples/advanced.py
# Launch interactive dashboard
streamlit run app.py
# Run benchmarks
python benchmarks/measure.py
# Execute test suite
pytest tests/ -v --cov=src --cov-report=html
# Simple but flawed
import time
class NaiveRateLimiter:
def __init__(self, max_calls, window):
self.max_calls = max_calls
self.window = window
self.calls = []
def allow(self):
now = time.time()
# Clean old calls - O(n) operation!
self.calls = [c for c in self.calls
if now - c < self.window]
if len(self.calls) < self.max_calls:
self.calls.append(now)
return True
return False
# Problems:
# - Memory grows with request rate
# - O(n) cleanup on every call
# - Not thread-safe |
# Token bucket algorithm
import time
import threading
class TokenBucketLimiter:
def __init__(self, rate, capacity):
self.rate = rate
self.capacity = capacity
self.tokens = capacity
self.last_refill = time.monotonic()
self.lock = threading.Lock()
def allow(self, tokens=1):
with self.lock:
now = time.monotonic()
elapsed = now - self.last_refill
# Refill tokens
self.tokens = min(
self.capacity,
self.tokens + elapsed * self.rate
)
self.last_refill = now
if self.tokens >= tokens:
self.tokens -= tokens
return True
return False
# Advantages:
# - O(1) constant time
# - Fixed memory usage
# - Thread-safe
# - Supports bursting |
Metric | Naive Implementation | Token Bucket | Redis-Based | Improvement |
---|---|---|---|---|
Memory (1M calls) | 458 MB | 1.2 MB | 2.4 MB | 381x better |
Throughput | 12K ops/s | 890K ops/s | 45K ops/s | 74x faster |
Time Complexity | O(n) | O(1) | O(1) | Constant time |
Thread Safety | No | Yes | Yes | Production ready |
Accuracy | 94% | 99.9% | 99.9% | Near perfect |
MacBook Pro M1 Max 32GB Unified Memory macOS Ventura 14.2 Python 3.11.7 |
GitHub Actions CI Ubuntu 22.04 LTS Windows Server 2022 macOS 13 |
Database Testing PostgreSQL 14 & 15 Redis 7.2 MongoDB 6.0 |
Performance assumptions are always wrong. I benchmark before optimizing anything. |
Unit tests for logic, integration tests for behavior, benchmarks for performance claims. |
Code shows what, comments explain why. Especially for non-obvious optimizations. |
Interactive demos make complex patterns intuitive and memorable. |
%%{init: {'theme':'base', 'themeVariables': { 'primaryColor':'#FFE4E1', 'primaryBorderColor':'#8B7D8B', 'primaryTextColor':'#4A4A4A', 'lineColor':'#DDA0DD', 'fontFamily':'Georgia, serif'}}}%%
flowchart LR
A[Fork<br/>Repository] --> B[Create Feature<br/>Branch]
B --> C[Add Tests &<br/>Benchmarks]
C --> D[Format<br/>Code]
D --> E[Submit<br/>PR]
E --> F[Code<br/>Review]
F --> G[Merge]
style A fill:#FFE4E1,stroke:#8B7D8B
style B fill:#EDE5FF,stroke:#8B7D8B
style C fill:#F0E6FF,stroke:#8B7D8B
style D fill:#FFF0F5,stroke:#8B7D8B
style E fill:#FFEFD5,stroke:#8B7D8B
style F fill:#F5DEB3,stroke:#8B7D8B
style G fill:#DDA0DD,stroke:#8B7D8B
β’ Include working examples with clear documentation
β’ Add comprehensive tests with edge cases
β’ Provide benchmarks for performance claims
β’ Format with black, isort, and ruff
β’ Document design decisions and tradeoffs
β’ Explain why, not just what
Quarter | Focus Area | Key Deliverables |
---|---|---|
Q1 2025 | Foundation & Core | Modules 1-10 complete with full test coverage |
Q2 2025 | Data Science & Web | Modules 11-17 with interactive visualizations |
Q3 2025 | Performance & Quality | Modules 18-20 with production patterns |
Q4 2025 | Advanced Topics | Modules 21-23 plus bonus content |
2026 | Second Edition | Distributed systems, cloud patterns, AI/ML operations |
All code is MIT licensed for maximum reusability |
Educational content is Creative Commons Attribution 4.0 |