Better HN
topnewbestaskshowjobs
Log inSign up

ngoldbaum

4,068 karma · joined Apr 22, 2013 (13y ago) · 404 submissions

Submissions

comment 1mo ago · link · parent

It should be good to go, but of course I don’t know what your codebase looks like and issues are always possible in any code, “good to go” or no. Please do give it a try and try testing on 3.15 and 3.15t.

comment 1mo ago · link · parent

I’m glad to see there’s ongoing work to get protobuf working!

I doubt PyUnstable APIs will get promoted directly to the limited API without at least a release or two in the regular version-specific API first.

That said, if you would be willing to start a thread on discourse describing your need and use-case, that is probably the first step to stabilizing the APIs you want. It may also turn out there’s an alternate way to get protobuf working.

Please do feel free to reach out privately. I’d love to be able to chat with people working on protobuf and grpcio, they come up reasonably often and it’s hard to get official updates from inside Google.

comment 1mo ago · link · parent

My headline feature is the new “abi3t” stable ABI for the free-threaded build. While Petr Viktorin did most of the CPython implementation, I’ve been trying to make sure ecosystem support is ready. It’s been a rewarding but quite challenging project to make sure everything is working. There were some late nights leading up to the beta1 release when we found a Windows-specific issue that needed a fix.

I’m particularly proud that the cryptography project is already shipping a single abi3.abi3t wheel for each platform on Python 3.15 or newer. The GIL-enabled build and free-threaded build can both use the same wheel now, because PyObject is opaque.

If you want to learn more about this, I gave a talk at EuroPython this year on Python’s ABI and the road to building and releasing abi3t today. See https://youtu.be/An8lO29SxXE.

4.

Python 3.15(python.org ↗)

318 points · by ngoldbaum · 1mo ago · 114 comments

5.

Teaching NumPy's ufuncs new tricks(labs.quansight.org ↗)

3 points · by ngoldbaum · 2mo ago · 1 comment

comment 3mo ago · link · parent

I’m saying that it’s a new issue on the free-threaded build.

comment 3mo ago · link · parent

There’s also the fact that INCREF and DECREF on shared objects is a lot more expensive than plain integer addition, so stuff becomes a bottleneck that was never a bottleneck. Kumar also fixed a bottleneck caused by a lock added only for safety on the free-threaded build. It’s hard to tell in advance than a fancy lock-free data structure is needed for something.

comment 3mo ago · link · parent

I’m not sure why it took me, a NumPy developer, looking at the benchmark numbers and saying “hmm, this is a bug”. But that is what it took. People are sometimes slow to treat behavior in dependencies like NumPy as bugs.

9.

Scaling NumPy on Free-Threaded Python(labs.quansight.org ↗)

114 points · by ngoldbaum · 3mo ago · 24 comments

comment 4mo ago · link · parent

I’m glad you enjoyed the post. It really helped me to crystallize my understanding. I was also confused about the API/ABI distinction for a long time.

comment 4mo ago · link · parent

Thanks for pointing that out, I’ll fix that.

12.

What Every Python Developer Should Know About the CPython ABI(labs.quansight.org ↗)

2 points · by ngoldbaum · 4mo ago · discuss

13.

Scaling Asyncio on Free-Threaded Python(labs.quansight.org ↗)

2 points · by ngoldbaum · 1y ago · discuss

comment 1y ago · link · parent

I wonder why the github status page has an atlassian cookie request pop-up.

15.

Python Free-Threading Guide(py-free-threading.github.io ↗)

2 points · by ngoldbaum · 1y ago · discuss

16.

The first year of free-threaded Python(labs.quansight.org ↗)

16 points · by ngoldbaum · 1y ago · 1 comment

comment 1y ago · link · parent

Either something about beanie babies or something riffing on "thank you". Couldn't ever make up my mind then basically forgot about it.

comment 1y ago · link · parent

I gave away the “ty” project name on pypi to Astral a week or so ago. I wanted to use it for a joke a few years ago but this is a much better use for a two letter project name. They agreed to make a donation to the PSF to demonstrate their gratefulness.

comment 1y ago · link · parent

You could do two passes over the string, first get the total length in bytes, then fill it in codepoint by codepoint.

You could also pessimistically over-allocate assuming four bytes per character and then resize afterwards.

With the API in the linked blog post it's up to the user to decide how they want to use the output [u8;4] array.

comment 2y ago · link · parent

The main difference is the strings are stored in a single contiguous arena buffer (with some minor caveats if you mutate the array in-place). With object strings each string has its own heap allocation.

More details in NEP 55: https://numpy.org/neps/nep-0055-string_dtype.html

This post is based on the content of a 25 minute talk and it’s hard to explain everything fully…

comment 2y ago · link · parent

Ah I could see how that’s confusing. I was trying to indicate that the size stored for the string in the example is 28, but it’s stored in a 64 bit uint.

comment 2y ago · link · parent

They’re stored on the DType instance. This requires that there’s only one DType instance per “owned” array buffer, which I figured out how to do along with Sebastian Berg and others using the new DType system.

comment 2y ago · link · parent

That is something I’d like to see but I don’t want to wade into the already very complicated discussion around arrow strings in pandas. If a Pandas developer wanted to take this on I think that would make things easier since there’s so much complexity around strings in Pandas.

That said there is a branch that gets most of the way there: https://github.com/pandas-dev/pandas/pull/58578. The remaining challenges are mostly around getting consensus around how to introduce this change.

If NumPy had StringDType in 2019 instead of 2024 I think Pandas might have had an easier time. Sadly the timing didn’t quite work out.

comment 2y ago · link · parent

This was a case of convergent evolution, both projects ended up working simultaneously on similar ideas.

One issue with using Arrow directly in NumPy is PyArrow exposes an immutable 1D array, while NumPy exposes a mutable ND array.

See also https://numpy.org/neps/nep-0055-string_dtype.html#related-wo...

comment 2y ago · link · parent

Well, there was no concept of sidecar storage. Now we have the hack we came up with for StringDType to store data on the DType instance and also make it so StringDType arrays don't share StringDType instances, unless the array is a view.

EDIT: looking back at the NEP, I'm not sure it does a great job explaining exactly how the per-array descriptor works. Ultimately it's powered by a hook in the DType API: https://github.com/numpy/numpy/pull/24988. There is only one spot in NumPy where array buffers are allocated, so we hooked there and made sure any arrays with newly allocated buffers get a new DType instance.

comment 2y ago · link · parent

Thank you this really means a lot.

comment 2y ago · link · parent

No, it wouldn’t make sense to. Use threading.Lock for that. PyMutex is available in the CPython C API.

comment 2y ago · link · parent

https://github.com/numpy/numpy/issues/26510#issuecomment-229...

And now that I look at that again I realize I forgot to finish that up!

12345
14