Live data from Hacker News

Uv saves Home Assistant 215 compute hours per month

developers.home-assistant.io

31–40 of 60 posts

Re: Uv saves Home Assistant 215 compute hours per month

#31

Every time I hear "new system faster than old system!", my first thought is: what features does the new system not implement, what corner-cases does it ignore? What are the trade-offs?

Yep. Reminds me of pnpm/npm/yarn. And then of every deprecation of a core pattern with a new™ and shinier™ replacement that lacks essential functionality deemed "a useless edge-case nobody uses because analytics say so".

Is it really a drop-in replacement for pip? If it's so that's great, then why not also officially replace pip?

Re: Uv saves Home Assistant 215 compute hours per month

#32

Earlier quoted context omitted.

Yeah but I suspect there’s something more going on than Rust magic. They’re claiming a savings of about an hour and a half. (4% of the original time) That sounds like an architecture change, or more likely a whole lot of caching.

I guess the uv authors don't want to maintain a better algorithm in Python then

I don’t know how you can seriously imply that Python could be just as fast as Rust if the authors of uv cared enough.

That seems like a disingenuous framing of why UV exists, let alone doesn’t pass the smell test that Python can just be as fast as a compiled, native machine code language. Python and Ruby and all that are just so god awful slow that it’s completely obvious that’s a rewrite in native code would have these sorts of benefits.

Re: Uv saves Home Assistant 215 compute hours per month

#34
post #4

Earlier quoted context omitted.

I’m guessing “rewrite it in Rust” would have been an unpalatable PR for the pip maintainers to merge.

Yeah but I suspect there’s something more going on than Rust magic. They’re claiming a savings of about an hour and a half. (4% of the original time) That sounds like an architecture change, or more likely a whole lot of caching.

Your assignment, should you choose to accept it, is to write a small, simple Python program. Maybe something that builds a list of five or six elements, runs a simple map over it, then converts it to a dict somehow. Something simple.

Then run it through gdb and watch every single CPU opcode that is executed for the code you wrote. Not Python opcode; CPU. Print something first and trigger off of that or something, I'm not worried about Python startup costs here.

Then do the same with a roughly equivalent compiled program. Doesn't have to be Rust, C or whatever you know would do just fine.

Yes. You can get a big speed improvement over pure Python simply by moving it to a compiled language and making effectively no other changes. Python is slow. This is not a value judgment. It is a big mistake to think that this is somehow an emotional judgment about Python stemming from anger or hatred or something and that anyone talking about Python's speed issues are just haters or something. I like Python just fine. But you will understand how it is not a value judgment when you are running the Python program through gdb. It is simply an engineering reality that anyone using Python needs to understand about Python. You can get yourself into a lot of trouble not understanding this about Python.

Is there more things going on than a straight port? Possibly. But I don't find the difference unbelievable for it to be coming from a straight port with no major changes.

Re: Uv saves Home Assistant 215 compute hours per month

#35
post #9

Earlier quoted context omitted.

Source on the logic being different from pip? Last I checked it's nothing more than a port of pip to rust.

I’m unclear on how you “port” a library from Python to Rust, it’s a ground up rewrite with a familiar interface to pip but fundamentally doesn’t share any code.

It's actually pretty easy to call python from rust and rust from python. An incremental port of a python library into rust would definitely be possible.

I'm not sure it would be a good idea. Python patterns don't necessarily make good rust patterns. Even ignoring larger code structure (e.g. single ownership*) you'd practically have to do a second pass to stop using python compatible types (except in the exposed interface) if you wanted an idiomatic rust library at the end of it. But it's definitely possible.

* Which you don't "have to" do in rust, you can use `Rc` everywhere and imitate python instead. It's just throwing some of the advantages of rust and adding some noise to type signatures.

Re: Uv saves Home Assistant 215 compute hours per month

#36

Every time I hear "new system faster than old system!", my first thought is: what features does the new system not implement, what corner-cases does it ignore? What are the trade-offs?

While uv supports a large subset of the pip interface, it does not support the entire feature set. In some cases, those differences are intentional; in others, they're a result of uv's early stage of development.

https://github.com/astral-sh/uv/blob/main/PIP_COMPATIBILITY....

Re: Uv saves Home Assistant 215 compute hours per month

#37

Earlier quoted context omitted.

Rust, the language, has rather successfully worked towards and demonstrated that, in many areas, you CAN have your pie and eat it too. But that doesn't carry over to applications, where it must be demonstrated again.

I’m doubtful the fact that uv is written in rust is directly responsible for the speed increase, it’s probably just a better dependency determination algorthm. Stop talking about fancy pies, you don’t need it even if it smells nice. What you actually need is to eat healthy and nutritious foods.

Feels like a mixed message, because my natural inclination would be to think of Rust as healthy and nutritious foods (it takes dedication and consistency to stick with it) and a better dependency algorithm as a fancy pie, since it's a on-off nice gain that feels good, but doesn't necessarily lead to additional benefits later.

Re: Uv saves Home Assistant 215 compute hours per month

#39
post #23

Every time I hear "new system faster than old system!", my first thought is: what features does the new system not implement, what corner-cases does it ignore? What are the trade-offs?

In my experience, most performance gains I've implemented have been moving to better data structures and not iterating the same thing a bunch of times.

Yup same

Re: Uv saves Home Assistant 215 compute hours per month

#40

Every time I hear "new system faster than old system!", my first thought is: what features does the new system not implement, what corner-cases does it ignore? What are the trade-offs?

Being 15 years old pip is limited by backwards compatibility constraints. The biggest performance gains actually don’t come from uv being written in rust as much as reworking the dependency resolver algorithm from the ground up.

As a result the full feature set of pip isn’t supported yet, but since it’s totally interoperable with your regular venv that’s not much of an issue (you can always fall back to pip).

I’ve been playing with it for a month and I can’t imagine going back to vanilla pip.

Post reply on HN