Protocols and Practices Enforcing in Python Through Bytecode and Inspection
EuroPython Conference via YouTube
Overview
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