python-fundamentals-313
БесплатноБез исполняемых скриптовНе проверенComplete Python 3.13+ fundamentals system. PROACTIVELY activate for: (1) Python 3.13 free-threading (no-GIL), (2) JIT compiler usage, (3) Pattern matching…
от JosiahSiegel★ 67 звёзд на GitHubОб этом скилле
Quick Reference
| Feature | Version | Syntax |
|---|---|---|
| Free-threading | 3.13t | python3.13t script.py |
| JIT compiler | 3.13 | PYTHON_JIT=1 python3.13 script.py |
| Pattern matching | 3.10+ | match x: case {...}: |
| Walrus operator | 3.8+ | if (n := len(x)) > 10: |
| Type params | 3.12+ | def first[T](items: list[T]) -> T: |
| Type alias | 3.12+ | type Point = tuple[float, float] |
| Construct | Code | Use Case |
|---|---|---|
| Exception Group | ExceptionGroup("msg", [e1, e2]) |
Multiple errors |
| except* | except* ValueError as eg: |
Handle groups |
| @dataclass(slots=True) | Memory efficient | High-volume objects |
| StrEnum | class Status(StrEnum): |
String enums 3.11+ |
When to Use This Skill
Use for Python 3.13+ fundamentals:
- Learning Python 3.13 new features (free-threading, JIT)
- Using modern pattern matching syntax
- Writing type-annotated generic functions
- Creating dataclasses and enums
- Understanding Python naming conventions
Related skills:
- For type hints: see
python-type-hints - For async: see
python-asyncio - For common mistakes: see
python-gotchas
Python 3.13+ Fundamentals
Overview
Python 3.13 (released October 2024) introduces significant performance improvements including experimental free-threading (no-GIL) mode, a JIT compiler, enhanced error messages, and improved REPL.
Python 3.13 New Features
Free-Threaded Mode (Experimental)
# Python 3.13t - Free-threaded build (GIL disabled)
# Use python3.13t or python3.13t.exe
import threading
import time
def cpu_bound_task(n):
"""CPU-intensive calculation that benefits from true parallelism"""
total = 0
for i in range(n):
total += i * i
return total
# With free-threading, these actually run in parallel
threads = []
for _ in range(4):
t = threading.Thread(target=cpu_bound_task, args=(10_000_000,))
threads.append(t)
t.start()
for t in threads:
t.join()
Key Points:
- Requires separate executable:
python3.13t - Build with
--disable-giloption - Best for CPU-bound multi-threaded workloads
- Scientific computing and data analysis benefit most
JIT Compiler (Experimental)
# Enable JIT with environment variable or flag
# PYTHON_JIT=1 python3.13 script.py
# JIT provides 5-15% speedups, up to 30% for computation-heavy tasks
def fibonacci(n: int) -> int:
"""JIT-optimized computation"""
if n <= 1:
return n
a, b = 0, 1
for _ in range(n - 1):
a, b = b, a + b
return b
# Hot loops benefit most from JIT compilation
result = fibonacci(10000)
Improved Interactive REPL
# New REPL features (automatic in Python 3.13):
# - Multiline editing with history preservation
# - Colored prompts and tracebacks (default)
# - F1: Interactive help browsing
# - F2: History browsing (skips output)
# - F3: Paste mode for larger code blocks
# - Direct commands: help, exit, quit (no parentheses needed)
Better Error Messages
# Python 3.13 provides:
# - Colored tracebacks by default
# - Suggests correct keyword if incorrect one passed
# - Warns when script name shadows stdlib module
# Example: If you name a file "random.py"
# Python now shows: "Note: File '/path/random.py' shadows the 'random' module"
Modern Python Syntax
Pattern Matching (3.10+)
def process_command(command: dict) -> str:
match command:
case {"action": "create", "name": str(name)}:
return f"Creating {name}"
case {"action": "delete", "id": int(id_)}:
return f"Deleting item {id_}"
case {"action": "update", "id": int(id_), "data": dict(data)}:
return f"Updating {id_} with {data}"
case {"action": action}:
return f"Unknown action: {action}"
case _:
return "Invalid command format"
# With guards
def categorize_value(value):
match value:
case int(n) if n < 0:
return "negative"
case int(n) if n == 0:
return "zero"
case int(n) if n > 0:
return "positive"
case float(f) if f.is_integer():
return "float-integer"
case str(s) if len(s) > 10:
return "long-string"
case _:
return "other"
Walrus Operator (:=)
# Assignment expressions
if (n := len(data)) > 10:
print(f"Processing {n} items")
# In comprehensions
filtered = [y for x in data if (y := transform(x)) is not None]
# In while loops
while (line := file.readline()):
process(line)
# Avoid in simple cases - prefer explicit assignment
# Bad: if (x := get_value()) > 0: use(x)
# Good: x = get_value(); if x > 0: use(x)
F-Strings (Enhanced in 3.12+)
# Basic f-strings
name = "World"
print(f"Hello, {name}!")
# Expressions
items = [1, 2, 3]
print(f"Sum: {sum(items)}")
# Format specifiers
value = 123.456789
print(f"{value:
Установить python-fundamentals-313 в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл python-fundamentals-313?
Complete Python 3.13+ fundamentals system. PROACTIVELY activate for: (1) Python 3.13 free-threading (no-GIL), (2) JIT compiler usage, (3) Pattern matching syntax, (4) Walrus operator, (5) F-string features 3.12+, (6) Type parameter syntax 3.12+, (7) Exception groups, (8) Dataclasses and enums, (9) Context managers. Provides: Modern syntax, performance features, best practices, naming conventions. Ensures correct Python 3.13+ patterns with optimal performance.
Как установить скилл python-fundamentals-313?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл python-fundamentals-313 запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic