Episode #218: Keyboards for developers, Python, and some history
Sponsored by Datadog: pythonbytes.fm/datadog
Special guest: Jeremy Tanner
Brian #1: Constant Folding in Python
- Arpit Bhayani
- Constant Folding is when a language replaces constant expressions at compile time rather than computing them at runtime.
- CPython does this while creating the bytecode.
- We can use
disto see it in action
>>> import dis >>> dis.dis("day_sec = 24 * 60 * 60") 1 0 LOAD_CONST 0 (86400) 2 STORE_NAME 0 (day_sec) 4 LOAD_CONST 1 (None) 6 RETURN_VALUE
- Python tries to fold lots of constants, but not all.
- Seems to be based on size
>>> x = 2 ** 64 # folded >>> x = 4 ** 64 # not folded >>> a = "-" * 4096 # folded >>> a = "-" * 4097 # not folded
- Discussion continues with a discussion of how CPython folding is implemented recursively and elegantly.
- Key takeaway for me:
- Remember to not try to pre-compute constants while coding.
- Make them easy to read and Python will handle the optimization for you.
Michael #2: Update All Packages With pip-review
- via PyCoders
- Updating Python packages can be a hassle.
- There are many of them - it's hard to keep track of all the newest versions
- When you decide what to update, you still have to update each of them manually.
- Originally a part of the
pip-toolspackage, it now lives on as a standalone convenience wrapper around
(venv) $ pip install pip-review (venv)$ pip-review scikit-learn==0.23.2 is available (you have 0.23.1) scipy==1.5.4 is available (you have 1.4.1) seaborn==0.11.0 is available (you have 0.10.1) ...
- Once you've identified if you'd like to update your packages, you can update them all, automatically, using
- Limit with constraints.txt file
- Can do it interactively via
Jeremy #3: Quantum Mechanical Keyboard Firmware
- How does the Python get into your computer? Much of it, through the keyboard
- Why mechanical keyboards?
- Where is QWERTY from?
- And when?
- and because it’s essentially an escape room built of hardware and open source software and dodgy international transactions
- I’ve fallen further down the mechanical keyboard rabbit hole
- Keyboard firmware is mostly written in c
- But there are Python portions
- Compiler helper
- So the CLI is Python, where else is Python?
- When looking to improve your keymap, key logging w/ Python to process logs for heatmaps
Brian #4: Reinventing the Python Logo
- Carlo Occhiena interview with Jessica Williamson
- Some cool logo history
Current, from 2006, designed by Tim Parklin
“The logo is actually based on mayan representations of snakes which very often represent only the head and perhaps a short length of tail. The structure of the snake representations the natural coiling/nesting of a snake as seen side on.” - Tim Parklin
Jessica Williamson proposed a new one in 2020:
Then there’s the rest of the article talking about the design process, etc.
- But….. just wanted to throw this out there. I’m happy with the 2006 version. - Brian
- MK: Have you ever seen the logos on the app stores?
Michael #5: Private PyPI with Serverless Computing
- Project: aws-lambda-pypi
- Brings together a few pieces so you can easily run a small PyPICloud instance as an AWS Lambda function with the help of Terraform.
- PyPICloud lets you publish Python packages privately.
- AWS Lambda lets you run a small service for free.
- Terraform ensures the service is deployed and maintained correctly.
- Security: This project takes the following security precautions.
- The session keys are auto-generated and stored in a secret.
- The server configuration file, which contains the session keys, is generated on the fly to minimize the possibility of exposure.
- The lambda function runs with a role limited to accessing only what it needs.
- PyPICloud is configured to display no packages to unauthenticated users.
Jeremy #6: Beyond the Basic Stuff w/Python
- Al Sweigart
- Want to become less feral?
- Twttier Haiku bot: @hitch_haiku
- Django 3.2 alpha 1 released
- mypy 0.800 with Python 3.9 Support
- pip 21.0 out and it drops Python 2
- Elastic changes open-source license to monetize cloud-service use
- We talked about pip-chill in episode 208
- pip-chill now has a
--no-chilloption to not list itself. Nice.
- pip-chill now has a
- I was just on https://www.twitch.tv/microsoftdeveloper, short, but fun
- via Wolf
developer: so i have good news and bad news
- manager: what's the good news?
- developer: i've discovered that the "5 second rule" only applies to food
- manager: and the bad news?
- developer: i dropped our tables