Brought to you by Michael and Brian - take a Talk Python course or get Brian's pytest book

#218: Keyboards for developers, Python, and some history

Published Wed, Jan 27, 2021, recorded Wed, Jan 27, 2021

Sponsored by Datadog:

Special guest: Jeremy Tanner

Watch this episode on YouTube
Play on YouTube
Watch the live stream replay

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

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?





  • 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, short, but fun


  • 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

Want to go deeper? Check our projects