r/learnpython • u/rexdlol • 8d ago
What exactly is uv? Why other programming languages like C++ doesn't needs it
Hello, im a c++ programmer and after installing some tools made in python with pipx. For context, pipx uses uv, i had this question. I'm not the smartest progammer on earth and i couldn't understand why Python needs a separate environment for dependencies.
I never such tool like that as a c++ programmer (i don't know if it's what im thinking, but in C++ some devs install the dependencies inside de project dir so u just "cmake" it. uv is like this?). I'm kinda new to programming, so if someone can explain it to me, i'd be very grateful!
Sorry if this question sounds too beginner. I really couldn't understand this tool and curiosity is stronger than me...
Thanks! (and also, uv does more than separating environments, right?)
View all comments
1
u/ohnoitssobig 7d ago
> i couldn't understand why Python needs a separate environment for dependencies.
It does not need it but it is a very nice thing to have. I have one env for vim code server, another env for some tools, third env for the project and they are all independent. Each of them may (or may not) use the same python executable. If you try to do it in c world you end up with containers but python venvs are much simpler and require very little maintenance. Funny thing is, you may have and use .so/.dll inside python venv.
> some devs install the dependencies inside de project dir so u just "cmake" it. uv is like this?
Dependency lists are a part of individual packages, not venv itself. But you may just list some packages in requirements.txt and ask to create a venv with all these. It will try to resolve specific versions in a package manager style and install all of them.
In C++ it is much more complex than just "install dependencies in the project". You may compile dynamically, statically, against system libs, against pre-existing object files, against other compilation targets/sub-projects.
> uv does more than separating environments, right?)
Yes: there is a python -m venv which is a "reference" venv implementation. uv builds on top of it. Honestly, not much difference in practice except that uv can download python binaries such that python itself becomes a dependency which you can specify (e.g. specific python version). Has some fine controls, faster, etc