#218 Keyboards for developers, Python, and some history
Python Bytes - Podcast tekijän mukaan Michael Kennedy and Brian Okken - Maanantaisin
Kategoriat:
Sponsored by Datadog: pythonbytes.fm/datadog Special guest: Jeremy Tanner Watch on YouTube 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 dis to 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-tools package, it now lives on as a standalone convenience wrapper around pip. Usage (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 pip-review --auto Limit with constraints.txt file Can do it interactively via pip-review --interactive Jeremy #3: Quantum Mechanical Keyboard Firmware How does the Python get into your computer? Much of it, through the keyboard Why mechanical keyboards? Ergonomics Where is QWERTY from? And when? Keymaps 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 RGBKB Sol Keyboardio Atreus Keyboard firmware is mostly written in c https://github.com/qmk But there are Python portions https://github.com/qmk/qmk_cli Compiler helper API Reporting So the CLI is Python, where else is Python? When looking to improve your keymap, key logging w/ Python to process logs for heatmaps https://github.com/qmk/qmk_firmware/issues/714 https://github.com/algernon/ergodox-layout/blob/master/tools/log-to-heatmap.py Brian #4: Reinventing the Python Logo Carlo Occhiena interview with Jessica Williamson Some cool logo history Early logo 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? Extras: Michael: 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 Brian: We talked about pip-chill in episode 208 pip-chill now has a --no-chill option to not list itself. Nice. I was just on https://www.twitch.tv/microsoftdeveloper, short, but fun Joke via Wolf by Kat Maddox 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