Skip to content

Add comprehensive Python knowledge base articles on advanced topics - #39

Merged
igormcsouza merged 2 commits into
mainfrom
claude/zealous-cori-0na6dl
Sep 29, 2026
Merged

igormcsouza merged 2 commits into
mainfrom
claude/zealous-cori-0na6dl

Conversation

@igormcsouza

Copy link
Copy Markdown
Owner

Summary

This PR adds six new comprehensive knowledge base articles covering advanced Python concepts, expanding the Python documentation with deep dives into language features and runtime behavior.

Key Changes

  • Context Managers — Explains the with protocol (__enter__/__exit__), class-based and generator-based implementations using @contextmanager, exception handling semantics, and contextlib utilities like ExitStack and suppress.

  • Closures and Lexical Scope — Covers the LEGB name resolution rule, how closures capture variables via cells, nonlocal/global declarations, the late-binding gotcha in loops, and practical use cases.

  • Decorators — Details the @ syntax and decoration mechanics, functools.wraps best practices, decorators with arguments (three-level nesting), stacking order and execution flow, and built-in decorators like @lru_cache and @contextmanager.

  • Multiple Inheritance & MRO — Explains the diamond problem, C3 linearization algorithm, how super() resolves to the next class in the MRO (not the literal parent), cooperative multiple inheritance patterns, and mixin design.

  • GIL, Threading, Multiprocessing and the Memory Model — Deep dive into why the GIL exists, when it's released, why it doesn't guarantee thread-safety, comparison of threading vs. multiprocessing trade-offs, memory models for each, and guidance on choosing the right concurrency model.

  • Cyclic Garbage Collector — Explains reference counting, how cycles break it, the generational GC algorithm, weak references, and practical debugging techniques for memory leaks.

Notable Details

  • All articles include runnable code examples and practical gotchas.
  • Cross-references link related articles (e.g., decorators → closures, context managers → metaprogramming).
  • Each article concludes with key takeaways and related reading.
  • The index is updated to include all new articles with brief descriptions.

https://claude.ai/code/session_01JTAb6TSso5fSPPNGoN1QiS

…GIL notes

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JTAb6TSso5fSPPNGoN1QiS
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JTAb6TSso5fSPPNGoN1QiS
@igormcsouza
igormcsouza merged commit 12b09b7 into main Sep 29, 2026
3 checks passed
@igormcsouza
igormcsouza deleted the claude/zealous-cori-0na6dl branch September 29, 2026 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants