Astral has been delivering impressive improvements to the Python ecosystem with ruff, taking over rye, and releasing uv to manage projects and Python installs. And there have been musings about when they'd release a type checker.
Well the alpha release is now here (via Patrick Kage). You can try it out:
# requires rust to compilecurl https://sh.rustup.rs -sSf|sh
uv add git+https://github.com/astral-sh/ty
uv run ty check
Note: It takes a little bit of time to compile ty, but like all the other Astral tools it runs very quickly.
Also: Fair warning, lots of stuff doesn't work yet. For example, when I tried it on my castfit library, it choked on dict() (see #100).
How long before ty replaces mypy and pyright in my build process for all my projects? I'll probably wait for the official release, but I'll probably try it at least once on all my projects just to see what it produces.
📝 Project Xanadu: Even More Hindsight (Gwern Branwen). In Minority Report they have "futuristic" interfaces where you wave your arms around to manipulate 3D projections. In the real world your arms would get very tired very quickly. Project Xanadu tried to create a hypertext environment with lots of guarantees, but Gwern's realization about the UX is notable:
“Oh my god. It’s completely unreadable.”
The lines were confusing clutter, especially as they crisscrossed (a perennial problem in sidenotes layout, made far worse by the outlines). None of the ‘sidenotes’ were readable because the screen was so small. Even as you simply scrolled, for many possible settings, you were unable to read anything! How could a document UI where often you could read nothing have ever seemed like a good idea? The UI was just terrible—it could never have worked. Even on a large screen like my 4k monitor, I wouldn’t want that.
The lesson?
So, to me, Project Xanadu is a case-study in why designers must mock-up and prototype their designs before too much is invested in them. Xanadu wasn’t the victim of “Worse is Better”; it was just a solution in search of a problem.
📝 Does AI Progress Have a Speed Limit? (Ajeya Cotra & Arvind Narayanan / Asterisk). Very respectful back-and-forth. I'm partial to Arvind's view, but I don't have enough evidence to support it.
When an AI system performs a task, human observers immediately estimate its general competence in areas that seem related. Usually that estimate is wildly overinflated.
People are surprised to discover that the prospective customer wouldn't even take your solution if it was free and had many other magical properties. This is an important signal.
You need to solve a burning pain. Even if it's a great idea and otherwise important, if it's not urgent, it's probably not relevant.
Towards the end of the post, there's a nice bit about "how you would find customers in this condition" that I thought was useful.
Like Auto-Tune for writing. GPTune takes someone’s normal idea and smooths it into something that feels more articulate, structured, erudite - but less authentic.
Ukrainian soldiers get reward points for destroyed Russian targets, which they can then exchange for new equipment. Just like in a game. - Politico.
The exchange happens through an online marketplace called Brave 1 and the troops need to provide video evidence to earn points.
♦️6 points for eliminating a Russian soldier
♦️40 points for destroying a tank
♦️50 points for taking out a mobile rocket system
For example, 43 points can get a powerful "Vampire" drone capable of carrying a 15-kg warhead.
What benefits?
♦️gets equipment directly to the most effective fighting units without bureaucratic delays
♦️motivates soldiers through friendly competition
♦️has already doubled the rate of Russian casualties since adjusting the point values.
♦️improves Ukraine's military intelligence by creating a verified database of Russian losses
📖 The Talmudic Argument by Louis Jacobs (1984; via Jeremy Wertheimer). Finally made some sense of a question I had since 8th grade: "Why didn't you just quote a few more words of that Braita earlier!?"
📝 Backfill your blog (Simon Willison). I took the time to convert 9 years worth of Keep In Touch emails into Markdown so that I can start a link blog starting today.
Memetically, being a Dangerous Professional means communicating in what might be a slightly adversarial context in a way which suggests that a bureaucracy take one’s concerns seriously and escalate them to someone empowered to resolve them swiftly.
During the code review for castfit, Gemini pointed me at attrs and cattrs. Many of the features of the attrs became dataclasses in the standard python library while the features of the cattrs look very similar to my own castfit library.
I started reading up on cattrs and I came across the article above which explains the three phases of optimization that cattrs went through. The first phase roughly corresponds to how castfit does conversions today. It also highlights the same problems I anticipate if castfit were to ever be used in a production environment.
The second (generated code) and third phases (optimized bytecode) reflect some very interesting optimizations. I'm glad that they kept the initial phase code around for situations where you don't have time up front (e.g., at CLI start up).
My simple test didn't work:
uv run --with cattrs python
>>>import cattrs
>>>classCat:... name:str... age:int...>>> cattrs.structure({"name":"Garfield","age":45}, Cat)
Traceback (most recent call last):
File "<python-input-2>", line 1,in<module>
cattrs.structure({"name":"Garfield","age":45}, Cat)~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../lib/python3.13/site-packages/cattrs/converters.py", line 558,in structure
return self._structure_func.dispatch(cl)(obj, cl)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
File ".../lib/python3.13/site-packages/cattrs/fns.py", line 22,in raise_error
raise StructureHandlerNotFoundError(msg, type_=cl)
cattrs.errors.StructureHandlerNotFoundError: Unsupported type:<class'__main__.Cat'>. Register a structure hook for it.
It turns out you need to use attrs or dataclasses to make this into an object that can be converted into:
castfit can handle the dataclass approach too, but for the undecorated version it just tries constructing an empty object and setting a bunch of attributes on it. Not sure if this is a reasonable assumption (probably isn't), but it reduces the number of required imports.