Numpy’s fromfile()/tofile() make me smile — no typing or byte order metadata, they just write/read the raw bytes. A joyful API! I wish PyTorch had them natively on tensors, so I wasn’t doing so many tensor.cpu().numpy() operations.

Sep 30, 2025 · 3:17 PM UTC

Replying to @ID_AA_Carmack
Someone from @PyTorch should read this and make it happen, safe to say we’d all love it!
3
Replying to @ID_AA_Carmack
If Python does something I need I will at once rewrite it in C. I have a little side project I call NumC. Rewrite everything Numpy in C. Grok makes this cheesy easy now.
3
11
Replying to @ID_AA_Carmack
Direct tensor I/O would be huge, especially for fast checkpoints and interop with non python systems. Surprising PyTorch hasn’t baked in raw binary read/write yet.
10
Replying to @ID_AA_Carmack
But you can use dtype argument to set its type and control endianness by prepending either ‘<‘ or ‘>’ to a type string: numpy.fromfile(path, dtype=‘>i4’)
5
Replying to @ID_AA_Carmack
Sometimes the simplest APIs are the most powerful and NumPy proves it every time. PyTorch could learn something here about not overengineering basic file operations.
3
Replying to @ID_AA_Carmack
Numpy one of the all time best apis ever created. Lightweight, fast, gets the job done
1
1
Replying to @ID_AA_Carmack
The leap from strong types to "here's some data of some type" is jarring for me. I always feel like I end up negating the prototype speed with having to compensate for ambiguous types. I'm not saying I want to have main() entirely comprised of pointer logic, but Python irks me.
1
Replying to @ID_AA_Carmack
safetensors for less joyful API
1
Replying to @ID_AA_Carmack
if only python allowed you to define a "def tofile(tensor): " function 🤔
1
Replying to @ID_AA_Carmack
Why didn’t the ML crowd adopt HDF5 files?
1
Replying to @ID_AA_Carmack
Carmack is going to make me wanna go learn Python, for real this time . . .
Replying to @ID_AA_Carmack
Makes for a great dodgy AF state cache
Replying to @ID_AA_Carmack
numpy sounds like grumpy. My man child woke up grumpy this morning. Its cute Mr. Carmack.
Replying to @ID_AA_Carmack
Hi John, we are putting on our second Game AI conference in Atlanta Feb. 21-22, 2026. Last year Luke Dicken, head of AI for Take-Two, was our industry keynote (ggda.org/transformer-2025). Can we talk about what would be involved in having you as a speaker? president@ggda.org
Replying to @ID_AA_Carmack
numpy is awesome, I wrote 90% of the code for my thesis with it, together with opengl python bindings, and a few C libraries for performance oriented code...never going back 😁
Replying to @ID_AA_Carmack
Read that as Numpty, which means idiot in local Scots
Replying to @ID_AA_Carmack
Maybe ask Claude 4.5 to do a PR on tensors @ID_AA_Carmack If your lucky, it might just work :)
Replying to @ID_AA_Carmack
There is this graphics library called Cairo that can export raw pixel data. You can feed a sequence of images to stdout, pipe that output into ffmeg, and tell it the format of the data, to turn it into a compressed video that you can play anywhere
Replying to @ID_AA_Carmack
If only more data types had this
Replying to @ID_AA_Carmack
Dedicated hw is the curse of the dedicated SW engineer
Replying to @ID_AA_Carmack
fromfile/to file is all you need?
Replying to @ID_AA_Carmack
it’s great to see such enthusiasm for clean apis.
Replying to @ID_AA_Carmack
@__tinygrad__ lets you do raw byte tensors: Tensor(Path("weights.bin"), dtype=dtypes.float32) keeps the file as storage; t.data() gives the bytes; t.assign(...) overwrites in place.