YoVDO

Protocols and Practices Enforcing in Python Through Bytecode and Inspection

Offered By: EuroPython Conference via YouTube

Tags

EuroPython Courses Static Code Analysis Courses

Course Description

Overview

Save Big on Coursera Plus. 7,000+ courses at $160 off. Limited Time Only!
Explore advanced techniques for enforcing protocols and best practices in Python through bytecode manipulation and code inspection in this 42-minute EuroPython Conference talk. Dive into the powerful introspection features of Python, including access to bytecode, to implement robust checks on third-party and future code. Learn how to verify and enforce constraints by examining the actual bytecode to be executed, going beyond traditional runtime checks, metaclasses, and monkeypatching. Discover practical examples of using these techniques to ensure proper resource management and prevent common anti-patterns, providing a more reliable alternative to static code analysis tools for custom checks and expectations in your Python projects.

Syllabus

Intro
Why? • Being more the Ubrary kind of developer tend to write a lot of independent pieces When you put those together to do the real job it's not always easy to comunicate their design and philosophy • Developers tend to do the best they can with what they have
Then comes documentation • To avoid misuses you try to cover examples for most reasonable use cases in documentation You quickly discover that your definition of reasonable is not as common as you thought
Protocols & Expectations • Protocols define how components interact with the rest of the world. Invest time in enforcing them and refuse violations • Developers have expectations out of your libraries your libraries should have expectations too
Protocols & Expectations • Protocols define how components interact with the rest of the world. Invest time in enforcing them and refuse violations.
Enforcing Protocols • Interfaces, Signatures. Types, Assertions are all ways to express a protocol. • They can provide expectations about joints between your code and users code . But they can do little about expectations on 'context where your library runs in
Enforcing Protocols Interfaces. Signatures. Types. Assertions are all ways to express a protocol • They can provide expectations about joints between your code and users code • But they can do little about expectations on context where your library runs in
The Context • Python is a Dynamic language with powerful inspection techniques.
The Context • Python is a Dynamic language with powerful inspection techniques • Inspection is often used for Debugging but it's a powerful tool to check expectations
The Context • Checking for anti-patterns is something static code analysis tools usually do But they are one more dependency and plece to integrate into build pipeline. They are usually pretty complex to adapt with custom checks if even possible. • They can check your code only
The Context • Checking for anti-patterns is something static code analysis tools usually do • But they are one more dependency and piece to integrate into build pipeline. • They are usually pretty complex to adapt with custom checks if even possible. They can check your code only
For Example? . I used code inspection to ensure no files are left behind clue to a failure in any method called when a resource is destroyed


Taught by

EuroPython Conference

Related Courses

A Brief History of Data Storage
EuroPython Conference via YouTube
Breaking the Stereotype - Evolution & Persistence of Gender Bias in Tech
EuroPython Conference via YouTube
We Can Get More from Spatial, GIS, and Public Domain Datasets
EuroPython Conference via YouTube
Using NLP to Detect Knots in Protein Structures
EuroPython Conference via YouTube
The Challenges of Doing Infra-As-Code Without "The Cloud"
EuroPython Conference via YouTube