HN user

ngoldbaum

3,882 karma
Posts54
Comments326
View on HN
labs.quansight.org 12d ago

What Every Python Developer Should Know About the CPython ABI

ngoldbaum
2pts0
labs.quansight.org 10mo ago

Scaling Asyncio on Free-Threaded Python

ngoldbaum
2pts0
py-free-threading.github.io 12mo ago

Python Free-Threading Guide

ngoldbaum
2pts0
labs.quansight.org 1y ago

The first year of free-threaded Python

ngoldbaum
16pts1
www.reuters.com 1y ago

Anaconda sued Intel for copyright infringement over AI software

ngoldbaum
2pts1
labs.quansight.org 2y ago

Free-threaded CPython is ready to experiment with

ngoldbaum
532pts378
blog.scientific-python.org 2y ago

NumPy 2.0: An Evolutionary Milestone

ngoldbaum
4pts0
labs.quansight.org 2y ago

Writing fast string ufuncs for NumPy 2.0

ngoldbaum
3pts0
peps.python.org 2y ago

PEP 725 – Specifying external dependencies in pyproject.toml

ngoldbaum
6pts0
cython.readthedocs.io 3y ago

Cython 3.0 Released

ngoldbaum
221pts82
gregoryszorc.com 6y ago

Mercurial’s journey to and reflections on Python 3

ngoldbaum
411pts367
gerikson.com 6y ago

Links shared between Lobste.rs, HN, and /r/Programming in the last 3 days

ngoldbaum
1pts0
joss.theoj.org 7y ago

Show HN: Unyt – Handle, manipulate, and convert data with units in Python

ngoldbaum
64pts4
github.com 8y ago

Show HN: Unyt – Handle, manipulate, and convert data with units in Python

ngoldbaum
1pts0
www.hdfgroup.org 8y ago

Announcing the Launch of the Enterprise Support Edition of HDF5

ngoldbaum
1pts0
github.com 8y ago

NumPy makes plans to drop Python2.7 support

ngoldbaum
15pts1
mail.python.org 8y ago

Scipy 1.0 released

ngoldbaum
370pts36
www.mercurial-scm.org 9y ago

SHA-1 and Mercurial security: why you shouldn't panic yet

ngoldbaum
3pts0
www.nature.com 9y ago

Seven earth-sized planets discovered circling a star 39 light years from Earth

ngoldbaum
2256pts704
www.snarky.ca 9y ago

Why I took October off from OSS volunteering

ngoldbaum
1pts0
blog.sentry.io 9y ago

Fixing Python Performance with Rust

ngoldbaum
331pts103
hubblesite.org 9y ago

Hubble Spots Possible Water Plumes Erupting on Jupiter's Moon Europa

ngoldbaum
2pts0
asmeurer.github.io 9y ago

Tuples

ngoldbaum
2pts0
github.com 9y ago

BSD 3-clause vs. MIT on GitHub

ngoldbaum
1pts0
jakevdp.github.io 9y ago

Conda: Myths and Misconceptions

ngoldbaum
3pts0
www.nature.com 9y ago

Earth-sized planet around nearby star is astronomy dream come true

ngoldbaum
11pts2
medium.com 10y ago

The Royal “We” in Scientific Software Development

ngoldbaum
7pts0
python3statement.github.io 10y ago

Python 3 Statement

ngoldbaum
3pts0
vakila.github.io 10y ago

Warming up to mercurial

ngoldbaum
3pts1
asmeurer.github.io 10y ago

Moving Away from Python 2

ngoldbaum
227pts275

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.

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.

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.

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.

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

This style of mutex will also power PyMutex in Python 3.13. I have real-world benchmarks showing how much faster PyMutex is than the old PyThread_type_lock that was available before 3.13.

Clarifying a few days later: single-threaded performance in the normal ABI with the GIL does not have the same performance degradation. You only see the performance hit if you’re testing the experimental 3.13 free-threaded release.

It’s an experimental release in 3.13. Another example: objects that will have deffered reference counts in 3.14 are made immortal in 3.13 to avoid scaling issues from reference count thrashing. This wasn’t originally the plan but deferred reference counting didn’t land in time for 3.13. It will be several years before free-threading becomes the default, at that point there will no longer be any single-threaded performance drop. Of course that assumes everything shakes out as planned, we’ll see.

This post is a call to ask people to “kick the tires”, experiment, and report issues they run into, not announcing that all work is done.

Right now there is a significant single-threaded performance cost. Somewhere from 30-50%. Part of what my colleague Ken Jin and others are working on is getting back some of that lost performance by applying some optimizations. Expect single-threaded performance to improve for Python 3.14 next year.

It’s a little easier to write idiomatic python bindings for a C/C++ library in Cython IMO, because you’re writing the bindings in a language that’s almost python.

I guess it’s mismatched expectations. IMO the primary use-case is making python wrappers for C/C++ code or converting prototype Python code into a fast C extension for production use by adding types or progressively converting code into a language that is a mix of Python and C.

Cython 3 also uses python type annotaions to infer C types now too, so if you add python types you might see surprising cython speedups.