On July 11, 2024, I had the pleasure of delivering a talk, The CPython Jit , at The Chicago Python Meetup Group . All of the slides, supporting details, links, repos, and live demos are available here. Slides Below are the slides presented along with the talk: Resources For more background on JITs and copy-and-patch specifically, see: PEP 744 - Jit Compilation : an informational PEP on the…
TL;DR To just build and run with the JIT: 1 2 3 4 5 6 # Install Python Build Dependencies (https://devguide.python.org/getting-started/setup-building/) git clone --depth 1 --branch v3.13.0b3 https://github.com/python/cpython.git cd cpython ./configure --enable-experimental-jit make ./python -c $'x=0\nfor i in range(5000):\n x+=i\nprint(x)' To include some debug output, to show the JIT is running:…
I had a lovely chat at on the floor at PyCon US with Ian Davies at Anvil , and specifically their newly launch py.space product. In short - it's a stripped down/streamlined version of Anvil that's being offered free to users to write online Python applications. This is going to be just my lab notebook as a stumble through the product for 45 minutes before the next talks. Ian demo'd a bunch of…
On May 17, 2024, I had the pleasure of delivering a talk, Make Your Documentation Interactive with PyScript , at PyCon US in Pittsburgh . All of the slides, supporting details, links, repos, and live demos are available here. Slides Below are the slides presented along with the talk: Demos and Repos To keep the sample/demo sites readable, they are each hosted in a separate repository. They are: A…
Life moves fast! In the midst of buying a house, a rapid public launch at my day job, and the other vagaries of real life, I haven't kept up with all the stunning releases that PyScript has had in the first quarter of 2024. That changes today! This post will cover all of the new and changed features since version 2024.1.1 . That includes PyScript versions: 2024.1.2 , 2024.1.3 , 2024.2.1 , 2024.3.1…
Type python on the left, and see the disassembly on the right. Offset Opname argrepr Line No Adaptive --> The source for this page is hosted on GitHub , if you want to check it out.
New Year, New Features! PyScript had it's first release in 2024 today with the release of PyScript 2024.1.1 . A few banner new features have been added, including: The mip package manager is now available for Micropython pyscript.js_modules now acts like a module The internal xterm.js terminal of scripts with a terminal attribute is exposed. With four releases in under three months, PyScript is…
The PyScript team just cannot be stopped - three releases out so far between Halloween and Christmas. And having remade the world just a few weeks back, the runway is free and clear to add some really neat features. In today's 2023.12.1 release release, there's three big ones: <py-editor> (the supercharged version of the old py-repl ) 'Managed' import of JS modules in Python document is…
Where does the time go?? Surely it can't be time for another Advent of Code challenge? Alas, it's once again December, which means 25 more mini coding challenges for the next twenty five days. This will be my sixth year particpating in advent of code, and my fourth writing about it - you can check out my previous years' Advent of Code posts as well, if you like. As in years before, I'll be writing…
With the 2023.11.1 release of PyScript behind us, i.e. the 'break the world' release, the PyScript team is looking to push out releases more frequently. We're hoping to integrate both quality-of-life and significant feature improvements at a faster pace, and to push out releases to match. With that, today PyScript released version 2023.11.2 ! You can see the detailed changelog here . It's worth…
Today marks the release of PyScript 2023.11.1 , a ground-up total-rewrite of PyScript that adds a wide swath of new functionality, smaller file sizes, faster loading, and so much more. This post (and really, this release) is a doozy, so get your brains in gear. You read that right - all of PyScript has been re-written from the ground up. While as many features and behaviors as possible have been…
PyScript has released version 2023.05.1 today! Between the big push to PyconUS 2023 , the ensuing sprints and the following flurry of enthusiasm, it's been a busy couple of months. There's been some significant bonuses to functionality, in parallel with a backend overhaul that'll be dropping in a future version. As always, you can see a Published Changelog for additional changes and bugfixes. But…
When writing Python code to run in the Browser (whether in PyScript or Pyodide), one common desire is to print something out to the page as the program progresses. Maybe it's status messages from phases of execution, or warning messages, or informational updates. In their simplest form, they might look like: button.html 1 < div id = 'myDiv' ></ div > PyScript Pyodide 1 2 for i in range ( 100 ):…
The Most Common PyScript Error There's one stumbling block that new PyScript users trip on more than any other [1] , and it's encapsulated in the following error message you may have seen gracing the top of your page: (PY0001): PyScript: Access to local files (using 'Paths:' in <py-config>) is not available when directly opening a HTML file; you must use a webserver to serve the additional files.…
PyCon 2023 Slides At the PyScript tutorial at PyConUS on Wednesday April 19, 2023, I had the privilege to present two short sections of slides: one on Python/JS interoperability, and one on Event Handling. The slides for these sessions, as presented, are included below. The slides are created in reveal.js using a 2D layout, i.e. slide progression is both vertical and horizontal. The 'chapters' run…
Pycon US is almost upon us! After Peter Wang's dynamite keynote launching PyScript at PyCon US 2022, the team is back again with a swath of interesting talks, tutorials, and topics in Salt Lake City this year. If you're interesting in PyScript, or Python on the web in any form, I'd highly encourage you to check these out. Update 6/2/23: Links to the recordings of each talk have been added.…
PyScript - the JavaScript library that lets you write Python right inside your HTML - is deliberately easy to use. Include a <script> tag, optionally a <link type='css'> for styling, and you can start dropping Python into your page. Easy. But what about all the other parts of Putting Stuff on the Web that are harder? What if you want to host your page with PyScript somewhere? Or share it with a…
import js loaded_event = js.Event.new('pyscript_ready') js.document.dispatchEvent(loaded_event) The PyScript team is absolutely steamrolling ahead in the past few months, working toward a new version of the PyScript open source library and some other developments that will become visible in the near future. (I hate to be a tease, but this isn't my piñata to pop). What follows is a writeup of the…
A user came along the PyScipt GitHub Discussions the other day with an interesting question - can you use PySerial (or similar) in PyScript? That got my wheels a turning; this post is the answer to that question. The short answer is no, PySerial doesn't work in PyScript - PySerial and other serial libraries rely on low-level features of their host operating systems which just aren't present in the…
In February 2023, I gave a talk on PyScript at the Chicago Python Users Group (Chipy) . The meeting was held in-person at Kitchen 17, and streamed/recorded at the time. And what a good time it was! Below are the slides for the talk, which you can also view at this link
plugins = ['build/pyxterm.min.js'] This is a (very rough) demo of a multilayered project called Emscripten Shell ( EmShell for short) Currently, the project encompasses three different levels of usage (which really should be three separate projects): The Emscripten-Shell itself, which is written in TypeScript/JavaScript and can be used with any program that uses the Emscripten Filesystem using the…
import js loaded_event = js.Event.new('pyscript_ready') js.document.dispatchEvent(loaded_event) Another couple months have flown by, and PyScript has a shiny new release: PyScript Version 2022.12.1 is now live! . What follows is a walkthrough of the changes since 2022.09.1, as well as notes on what's changed in the development process, the community, and what's coming next. What's not covered here…
Another year, another 25 curious code challenges from Advent of Code! This year, I'll be attempting to make as many solutions as possible something you can run right here in your browser window via PyScript . Table of Contents packages = ['anytree', 'rich'] terminal = false [[fetch]] files = ['utils.py'] [[fetch]] from = './day10' files = ['addition.py', 'computer.py', 'instruction.py',…
The Problem Pyodide has an almost-magical ability to proxy objects and functions between Python and JavaScript in both directions... except when sometimes it seems to mysteriously break. Consider this stumbling block that new users often hit: 1 2 3 4 5 6 7 8 9 < button id = 'my_button' > Say Hello </ button > < py - script > from js import console, document def hello ( * args): console . log(…
When running Python in a terminal or desktop, there's a myriad of ways to allow your code to do multiple things at once. You can spin off a new thread to handle computations, create a new process to offload work to other CPUs, even load up a while new subinterpretter (someday!) to execution more code. When running Python in the Browser, you get one process and (at least for now) one thread. That's…
PyScript Version 2022.09.1 was just released , and just as tech lead Fabio Pliger said in proposing the versioning scheme: '...An important aspect to keep in mind is that PyScript is still in its very early stages. So, we should highlight that the expectations should be that think can often break until we reach a level of maturity and stability.' And wow, are there a lot of new things in this…
- rich - faker - paths: - ./_richsetup.py - ./scripts/liverunner.py #click Text button to start from js import document document.getElementById('button1').click() Rich is a Python library for writing rich text (with color and style) to the terminal, and for displaying advanced content such as tables, markdown, and syntax highlighted code. The page illustrates the core classes and concepts of the…
As I've been diving deep into PyScript the past couple months, I've developed a handful of shortcodes for Hugo that make it quicker and easier to display code snippets on the page in a nicely formatted way. We'll use the following Python code as the source to be formatted. The code below is displayed by simply wrapped it in a pair of <pre></pre> tags: class hello_sayer: def __init__(self, greeting…
A question I've been seeing quite a bit over in the Unofficial PyScript Community Discord is: How do you pass objects back and forth between JavaScript and PyScript/Pyodide? So I've created recipies below for passing objects back and forth between JavaScript and Python; the specifics are somewhat different depending on whether we're working in PyScript or directly in Pyodide, so both options are…
A curious dev on the PyScript Discord (which you should really come check out) asked: I am taking file input in HTML where I am selecting image, how to show image when submit button is hit in PyScript? Actually, I need to use that file in PyScript to process. How can I do that? Well, there's an interesting question. How do we deal with uploaded files in Javascript/Pyscript? For those looking to…
Since its announcement at PyCon 2022 , the Python community has been buzzing about PyScript , a framewok for creating and running Python applications in the browser. Below are implementations of 'The 7 GUIs' UI Challanges in PyScript, which hopefully will hopefully be educational for those looking to get into writing Python for the web. (They were certainly educational to create.) For source code,…
This post is a companion to my project The 7 GUIs in PyScript - I recommend checking out that page first. Viewing on Desktop is highly recommended. The Seven Guis is a set of typical challenges in GUI programming. Implementations abound , in lower-level frameworks like tcl and Qt to modernist frameworks like React and Svelte. Let's see what it takes to implement them in PyScript. Counter 'The task…
Installation is simple, as noted on the Github repository : clone the repo, cd into the pyscriptjs folder, run npm install and you're good to go. npm run dev starts a live server for playing with code or examples. You can also just include Pyscript via CDN. Looking at the core part of the hello_world example shows us a few things: hello_world.html 1 2 3 4 5 6 7 8 9 < body > Hello world! < br >…
I was digging around in the available statistics for this very site on my Cloudfront Distribution , when I came across an interesting chart. Wow, almost 2500 hits to my Cloudfront cache on 3/8! My site must be getting so much traffic! Or is it? Let's dig futher into the cache stats and see what's happening. The next charge on this page shows percentage of viewer requests by result type and... it…
Tl;DR Computers hate having their power abruptly cut. A UPS, an Adafruit Feather board, and some python hackery keeps computers booting and shutting down gracefully when power is yanked and restored, deliberately or not. Update: The comments on the Hackaday post had a lot of other interesting solutions, some of which I'd considered and some of which I didn't. Skip to the Other Solutions for…
As part of transitionining from my old wordpress site to this new one created with Hugo, I wanted to be sure to preserve any external links that pointed to URLs that may no longer exist in Hugo's content structure. In partilcular, the format of permalinks to my blog posts has changed from /year/date/post-name to just /post/post-name . Additionally, I had created 301 redirects from several short…
At USITT 2022, I was fortunate enough to present as part of a panel session on Homemade LED Projects. The session focused on introducing electronics makers of all skill levels to the skills and vocabulary they need to make things with LEDs. We covered different LED types, power supplies, wiring methods, safety concerns, design processes, and so much more. Along with my wonderful teammates - Chris…
In January 2022, I had the pleasure of operating in the Winter Field Day 2022 ham radio event. The event, a volunteer run spinoff of the long-running ARRL Field Day encourages operators to move their radios out in the the wider, chillier world. While the ARRL field day has an explicit emphasis on disaster preparedness and mobility, Winter Field Day is as much about having a fun contest in the…
One thing I'd like to have for both my Demilight project page and the homepage is an automatically generated gallery of thumbnails of my recent YouTube uploads, either from a specific playlist or from all of my uploads. Unfortunately, this doesn't seem to be a straightfoward thing to do with YouTube's built-in embedding tools. But perhaps we can figure out a way to do so using the YouTube Data Api…
Back to Table of Contents Is it Advent of Code time again? Well, here goes nothing. Let's see wha we can cook up. I'm planning on completing most (all) of this year's challenges in Python, same as last year . Table of Contents Day 1 - Sonar Sweep Day 2 - Dive! Day 3 - Binary Diagnostic Day 4 - Giant Squid Day 5 - Hydrothermal Venture Day 6 - Lanternfish Day 7 - The Treachery of Whales Day 8 -…
I'm setting out to rectify a pretty silly part of my workflow. Namely, when I want to push new content to the site that I've built with hugo, I: Clean my current hugo build locally (removing /public, /resources/ and /dist). Slightly unnecessary, but has cleared some issues in the past. Rebuild all files using npx hugo Add all files to git using git add -A Commit the new files using git commit -m…
I tasked myself with overhauling one of the lighting control closets at work. This used to house a 1995 Unison Heritage lighting controller for archetectural control, as well as an MA2 remote playback unit to control some LED fixtures and moving lights. It was all housed in an abysmal rolling rack with no connectors on it; why the rack needed to roll is beyond me. I packaged it up into a…
The site's coming along well now! But there's just one small problem - specifically, how the site looks on mobile devices, or even just devices smaller than fullscreen. In short, bad. That design is just straight-up mobile antagonistic. Thankfully, Chrome's dev tools have a very handy device toolbar that forces the sites dimensions to be that of any of a number of common mobile devices, or allows…
As the site gains more and more content, it seems like it's only a matter of time before I port my previous blog(s) over to the Hugo framework that I'm enjoying so much. This would include at least the current Wordpress blog hosted at Jeff.Glass, as well as potentially importing old posts from my ham radio blog, kk9jef.wordpress.com. The Hugo documentation has some information on exporting from…
At this point, I feel I have the theming and functionality of hugo pretty well in hand. So I'll delete the 'Blank' theme that I started with, remove references to it from Config.toml and .gitmodules, and see what breaks. Looks like it's just the 'pagination' partial, which I'm using to drive the list page layouts. I'll just copy the pagination.html partial back in from the blank theme and... we're…
My work often involves switching between several computers - a laptop, a beefier desktop, an ‘IT Sanctioned’ clean machine with access to the work network, and a temporary line to whatever computer’s on the workbench. To improve the ergonomics of using the KVM switch, I designed and 3D-printed a small stand to hold the switch controls, then labelled it using an old embossing Dymo…
One of the earliest homebrew ham radio transceivers I built was a direct-conversion receiver for the 40m band. I packaged it in the aluminum box of the “Lose Your Virginity” kit I had been given as a gag gift by some friends, and therefore christened it “The Virgin Receiver.”
One of our retrofit projects at work required using four small DAC boards to converet 0-5V PWM into true 0-10V analog voltage. I designed and printed some small snap-on DIN rail mounts for these to cleanly mount them in their enclosure.
As I figure out my workflow for creating pages, especially the 'One Offs', I want to keep things as simple and straightforward as can be for adding new content. The intention of the One Offs is a place to memorialize small, interesting things - things that shouldn't disappear into twitter, but aren't a full project writeup. To that end, I'd like to have some standard formatting for all of their…