frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Open in hackernews

HRT's Python fork: Leveraging PEP 690 for faster imports

https://www.hudsonrivertrading.com/hrtbeat/inside-hrts-python-fork/
30•davidteather•3h ago

Comments

davidteather•3h ago
The author interviewed me and talked about this project, so it was cool seeing a blog post posted about it
rirze•2h ago
Oh, it's a trading firm. That's why they can fund an internal fork of Python... That sounds nice...
rasjani•2h ago
I know few modules that can take seconds to import but would have been nice to hear how much they actually gained?

Also maybe, if this approach could yield stats on if some import was needed or not ?

fabioz•1h ago
It'd have been really nice to have that PEP in as it'd have helped me not have to write local imports everywhere.

As it is, top-level imports IMHO are only meant to be used for modules required to be used in the startup, everything else should be a local import -- getting everyone convinced of that is the main issue though as it really goes against the regular coding of most Python modules (but the time saved to start up apps I work on does definitely make it worth it).

zzzeek•1h ago
Gonna call this an antipattern. Do you need all those modules imported in every script ? Well then you save nothing on loadup time, the time will be spent regardless. Does every script not need those imports ? Well they shouldn't be importing those things and this small set of top level imports should be curated into a better, more fine grained list (and if you want to write tools, you can certainly identify these patterns using tooling similar to that which you wrote for LazyImports).
sunshowers•1h ago
There are often large programs where not every invocation imports every module.

The lazy import approach was pioneered in Mercurial I believe, where it cut down startup times by 3x.

spicybright•1h ago
For personal one file utility scripts, I'll sometimes only import a module on a code path that needs it. And make it global if the scope gets in the way.

It's dirty, but speeds things up vs putting all imports at the top.

its-summertime•9m ago

    import argparse
    parser = argparse.ArgumentParser()
    parser.parse_args()
    import requests
Is an annoying bodge that a programmer should not have to think about, as a random example
ecshafer•1h ago
I thought HRT was a Cpp shop? Is Python used in their main business applications, or more for quants / data scientists?
almostgotcaught•1h ago
every quant shop has QR and QT people that can barely write passable python let alone cpp - then the QD people have to integrate that stuff with prod cpp pipelines.
roadside_picnic•55m ago
Interviewed with HRT awhile back. While I didn't get past the final round, their Python internals interview (which I did pass) was an absolute blast to prepare for, and required a really deep dive into implementation specific details of CPython around things like exactly how collisions are handled in dict, details about memory management, etc. Pretty much had to spend a few weeks in the CPython source to prep, and was, for me, worth the interview just to really learn what's going on.

For most teams I would be pretty skeptical of a internal Python fork, but the Python devs at HRT really know their stuff.

htrp•18m ago
when milliseconds mean millions
nly•16m ago
I interviewed with them as well. Something like 6-8 interviews only to be told they then, after that, were circulating my CV amongst teams and didn't have a fit for me...

But yes, like you I had a great experience

Spivak•52m ago
> This process gets dramatically slower for … modules on distributed file systems, modules with slow side-effects

Oh no. Look I'm not saying you're holding it wrong, it's perfectly valid to host your modules on what is presumably NFS as well as having modules with side effects but what if you didn't.

I've been down this road with NFS (and SMB if it matters) and pain is the only thing that awaits you. It seems like they're feeling it. Storing what is spiritually executable code on shared storage was a never ending source of bugs and mysterious performance issues.

globular-toast•43m ago
Imagine if these guys put their intelligence towards improving the world.
patrick91•39m ago
I really really want lazy imports in Python, it's would be a godsend for CLIs
nasretdinov•15m ago
I wonder how much can be saved by using a local file system for imports though. In my testing just a mere presense of a home directory on NFS already dramatically slows down imports (by ~10x) due to Python searching for modules in home directory too by default.
its-summertime•4m ago
> There’s also no way to make imports of the form from module import * lazy

I'd say if you see

    from typing import Final
    [...]
    __all__: Final = ("a", "b", "c")
Its probably 99% safe to pull that from a quick run over of the AST (and caching that for the later import if you want to be fancy)

Of course, should one be doing a star import in a proper codebase?

Gold futures jump to record high after US tariffs on cast bars – Gold

https://www.theguardian.com/business/2025/aug/08/gold-futures-soar-to-record-high-after-reports-of-us-tariffs-on-swiss-bars
1•rbanffy•43s ago•0 comments

Efrit: A native elisp coding agent running in Emacs

https://github.com/steveyegge/efrit
2•simonpure•2m ago•0 comments

OpenAI bringing back GPT-4o to ChatGPT Plus users

https://old.reddit.com/r/ChatGPT/comments/1mkae1l/comment/n7nelhh/
2•rob•6m ago•0 comments

Show HN: New Angular OpenAPI Client gen (looking for testers)

https://ng-openapi.dev/
1•tjami•7m ago•0 comments

Ask HN: Does No Response Mean a Bad Idea?

1•samehsbs•7m ago•1 comments

Jim Lovell Has Died

https://en.wikipedia.org/wiki/Jim_Lovell
2•ColinWright•9m ago•1 comments

ChatGPT Will Apologize for Anything

https://www.aiweirdness.com/chatgpt-will-apologize-for-anything/
3•xnx•9m ago•0 comments

Apollo 13 Commander Jim Lovell has passed away

https://www.nasa.gov/news-release/acting-nasa-administrator-reflects-on-legacy-of-astronaut-jim-lovell/
4•LorenDB•10m ago•0 comments

Show HN: HackMaster Pi – A $30 Flipper Zero Alternative Built with Raspberry Pi

https://github.com/1PingSun/HackMaster-Pi
1•1ping•11m ago•0 comments

How to Teach Your Kids to Play Poker: Start with One Card

https://www.bloomberg.com/news/articles/2025-08-08/how-to-teach-your-kids-poker-with-one-card-at-age-four
1•ioblomov•11m ago•1 comments

ChatGPT-5 Can't Do Basic Math

5•MarcellusDrum•15m ago•0 comments

Security alerts in Gmail. What a mess

2•chrisjj•16m ago•0 comments

GPT-5 AMA

https://www.reddit.com/r/ChatGPT/s/37th7HY644
2•IdealeZahlen•17m ago•0 comments

Johns Hopkins is building its AI wargaming tools for DoD

https://breakingdefense.com/2025/08/johns-hopkins-is-building-classified-versions-of-its-ai-wargaming-tools-for-dod-ic/
1•geox•18m ago•0 comments

Fears of population collapse in the US are based on faulty assumptions

https://theconversation.com/fears-that-falling-birth-rates-in-us-could-lead-to-population-collapse-are-based-on-faulty-assumptions-261031
2•PaulHoule•18m ago•0 comments

GPT-5 Rollout Updates

https://twitter.com/sama/status/1953893841381273969
3•tosh•20m ago•0 comments

Cordoomceps – replacing an Amiga's brain with Doom

https://mjg59.dreamwidth.org/73001.html
3•LorenDB•20m ago•0 comments

Millions are flocking to grow virtual gardens in Roblox game created by teenager

https://apnews.com/article/roblox-game-grow-garden-trend-2f5e4368448d57002d08b1b3d4a289ca
1•petethomas•23m ago•1 comments

The Illustrated TLS 1.2 Connection

https://tls12.xargs.org/
1•dmazin•24m ago•0 comments

The surprising economics of the meat industry – Lewis Bollard

https://www.dwarkesh.com/p/lewis-bollard
2•paulpauper•24m ago•0 comments

Job growth has slowed sharply; the question is why

https://stayathomemacro.substack.com/p/job-growth-has-slowed-sharply-the
17•paulpauper•24m ago•6 comments

Campaigning for Extinction:Eradication of Sparrows and the Great Famine in China

https://www.nber.org/papers/w34087
1•paulpauper•25m ago•0 comments

GRETA to Open a New Eye on the Nucleus

https://newscenter.lbl.gov/2025/08/08/greta-to-open-a-new-eye-on-the-nucleus/
1•gnabgib•25m ago•0 comments

HTTP Is Not Simple

https://daniel.haxx.se/blog/2025/08/08/http-is-not-simple/
5•thunderbong•27m ago•2 comments

Looking for Testers for an AI Privacy Platform

https://scanonai.carrd.co
1•lotuslabs•28m ago•1 comments

Three Tiers of Responses to Fact

https://medium.com/on-history/three-tiers-of-responses-to-fact-9b551f2a4fb6
2•wsgeorge•31m ago•0 comments

Toxic convenience: what science tells us about plastic's hidden costs

https://www.rfi.fr/en/international/20250808-toxic-convenience-what-science-tells-us-about-plastic-s-hidden-costs
2•everybodyknows•32m ago•0 comments

ChatGPT users hate GPT-5's overworked secretary energy, miss their GPT-4o buddy

https://arstechnica.com/ai/2025/08/chatgpt-users-outraged-as-gpt-5-replaces-the-models-they-love/
7•rntn•33m ago•0 comments

Welcome to DIY Rich Guy Fantasy Camp

https://www.theglobeandmail.com/arts/article-diy-rich-guy-fantasy-camp-mandle-cheung-bezos-ackman/
2•throw0101a•36m ago•1 comments

FIN - Fish Extensible Text Editor Written in Fish

https://codeberg.org/Digit/fin/
2•ashitlerferad•36m ago•0 comments