Episode #177: Coding is 90% Google searching or is it?
Sponsored by Datadog: pythonbytes.fm/datadog
We’re launching a YouTube Project: pythonbytes.fm/youtube
- “The Packaging Working Group of the Python Software Foundation is launching an all-new sponsorship program to sustain and improve Python's packaging ecosystem. Funds raised through this program will go directly towards improving the tools that your company uses every day and sustaining the continued operation of the Python Package Index.”
- Improvements since 2017, as a result of one time grants, a contract, and a gift:
- relaunch PyPI in 2018
- added security features in 2019
- improve support for users with disabilities and multiple locales in 2019
- security features in 2019, 2020
- pip & dependency resolver in 2020
- Let’s keep it going
- We use PyPI every day
- We need packaging to keep getting better
- You, and your company, can sponsor. View the prospectus, apply to sponsor, or ask questions.
- Individuals can also donate.
Michael #2: energy-usage
- A Python package that measures the environmental impact of computation.
- Provides a function to evaluate the energy usage and related carbon emissions of another function.
- Emissions are calculated based on the user's location via the GeoJS API and that location's energy mix data (sources: US E.I.A and eGRID for the year 2016).
- Can save report to PDF, run silently, etc.
- Only runs on Linux
- Colin Warn
- Short article, mostly chosen to discuss the topic.
- Michael & Brian disagree, so, what’s wrong with this statement?
- Article by Chris Moffet
- VMs aren’t fair to Windows (or macOS or …)
- But you need to test on linux-y systems! Enter WSL.
- In 2016, Microsoft launched Windows Subsystem for Linux (WSL) which brought robust unix functionality to Windows.
- May 2019, Microsoft announced the release of WSL 2 which includes an updated architecture that improved many aspects of WSL - especially file system performance.
- Check out Chris’ article for
- What is WSL and why you may want to install and use it on your system?
- Instructions for installing WSL 2 and some helper apps to make development more streamlined.
- How to use this new capability to work effectively with python in a combined Windows and Linux environment.
- The main advantage of WSL 2 is the efficient use of system resources.
- Running a very minimal subset of Hyper-V features and only using minimal resources when not running.
- Takes about 1 second to start.
- The other benefit of this arrangement is that you can easily copy files between the virtual environment and your base Windows system.
- Get the most out of this with VS Code +
- Derek D
- Again, mostly including this as a discussion point
- But for reference, here’s the decoder
- Single Responsibility Principle
- Every module/class should only have one responsibility and therefore only one reason to change.
- Open Closed Principle
- Software Entities (classes, functions, modules) should be open for extension but closed to change.
- Liskov's Substitutability Principle
- If S is a subtype of T, then objects of type T may be replaced with objects of Type S.
- Interface Segregation Principle
- A client should not depend on methods it does not use.
- Dependency Inversion Principle
- High-level modules should not depend on low-level modules. They should depend on abstractions and abstractions should not depend on details, rather details should depend on abstractions.
- Single Responsibility Principle
Michael #6: Types for Python HTTP APIs: An Instagram Story
- Let’s talk about Typed HTTP endpoints
- Instagram has a few (thousand!) on a single Django app
- We can have data access layers with type annotations, but how do these manifest in HTTP endpoints?
- Instagram has a cool
api_viewdecorator to “upgrade” regular typed methods to HTTP endpoints.
- For data exchange, dataclasses are nice, they have types, they have type validation, they are immutable via
- But some code is old and crusty, so
dictusage with validation still.
- OpenAPI can be used for very nice documentation generation.
- Comments are super interesting. Suggesting
fastapi, and more. But that all ignores the massive legacy code story.
- But one is helpful and suggests
Schemathesis: A tool for testing your web applications built with Open API / Swagger specifications.
"How many programmers does it take to kill a cockroach? Two: one holds, the other installs Windows on it."