Uv saves Home Assistant 215 compute hours per month
developers.home-assistant.io
developers.home-assistant.io
I guess the answer for now is "they don't".
What are the trade-offs?
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.
Is it really a drop-in replacement for pip? If it's so that's great, then why not also officially replace pip?
https://github.com/astral-sh/uv/blob/main/PIP_COMPATIBILITY....
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.
Getting to a consensus is hard work. They have a vision for how Python packaging and tooling could be better (I assume cargo-like), and a roadmap for improving that. They could have tried to convince the pip maintainers their roadmap was best, but with large fragmented communities like Python it is impossible to reason about how the community will receive changes to tooling. It’s better to build something and get feedback to prove the hypothesis.
The choice of Rust is just because they like the developer ergonomics in that language (I suspect a big reason is that they wanted to ship a single binary independent of any Python env). CPython is written in C because… Guido started to write it in C.
Many comments here don’t understand that their competitors are actually NOT just pip but the conda ecosystem including micromamba (written in C++) which does not attempt to maintain pip interop at all. Conda realized that there are millions of Python programmers who are not developers and could not debug a GCC error message when pip installing scipy.
There are thousands of Python packages that are basically tested on whatever version of Python and libraries the author had installed at the time they wrote it, and literally millions of Github issues that are something like “this doesn’t work because I installed version Y of package X and package Z requires < Y” all vaguely for solveable reasons. Many of these include C/C++ code that builds via custom setup.py scripts.
If you haven’t lost days of work to solving stupid dependency issues in Python I’m not sure you can relate.
Even then, I'm not sure how it would take 1.5 hours even on pen and paper.
Plain pip doesn't really have a lockfile. You can generate a freeze file, but that's something different in practice.
I haven't really been in the Python ecosystem in several years, but my surprise was mostly how there was no mention of Poetry or pipenv. Didn't they address that need before? Are they already out of favor?
uv looks like a good and fast replacement for pip or venv-update but those only take a fraction of a second to run (on a noop, my main use case) so I personally haven't seen where uv would fit in my workflow yet. Maybe building in containers from scratch each time, though again pip is performant enough for me when not doing the hard work of dependency resolution, and for some reason it's not cached.
I am not sure why dependency resolution outside of dev or build systems would be done. But maybe I have escaped the loop.
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.
As a concrete example, I have a raspberry pi 4 I use for "what's the most pathetic hardware a user might try". It takes 5-10 minutes to build up a fresh venv even when it has all of the packages cached. If I nuke the caches and make it download, it's 20+ minutes. For comparison a modern laptop takes ~1 minute.
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.
Last I checked it's nothing more than a port of pip to rust.
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<RefCell>` everywhere and imitate python instead. It's just throwing some of the advantages of rust and adding some noise to type signatures.
> Limitations
> 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.
> For details, see our pip compatibility guide[1]
> Like pip-compile, uv generates a platform-specific requirements.txt file (unlike, e.g., poetry and pdm, which generate platform-agnostic poetry.lock and pdm.lock files). As such, uv's requirements.txt files may not be portable across platforms and Python versions.
[1] - https://github.com/astral-sh/uv/blob/main/PIP_COMPATIBILITY....
Re: politics. Note that sometimes forks and competitors are so successful, they make it possible for the upstream to "unblock" by virtue of convincing them to adjust their vision. For Node.JS, consider io.js and Yarn in particular.
Why do you ask?
A compiler bug could put a bug in the compiler and propagate itself indefinitely.
An implementation in some other languages that has an implementation in C means you could theoretically start from ASM and rebuild.
For things like dependency resolution, where you're doing a lot of heavy CPU operations, there is a lot of room for optimization in lower level languages.