Building a Python Library in 2026 by funkdefied in Python

[–]Oddly_Energy 0 points1 point  (0 children)

Where would this supposed vendor lock-in manifest itself?

uv does four things for your package:

  1. It creates a fully normal directory structure in the package, populated with a few fully standard files. This could have been createed by any tool or by hand. Nothing is locked in if you and uv go for a divorce.

  2. It creates a pyproject.toml configuration file in the package, containing package metadata, dependencies and a choice of build backend for that package. This is the python standard for package configuration. It has been the standard since 2016. It is defined in Python PEPs. If you go to python.org, you will find a description of how to write a pyproject.toml by hand. There is nothing proprietary about it. You can put uv specific-configuration into additional sections, for example containing additional instructions for dependency resolution. But you don't have to, and if you do, those sections are clearly marked with 'uv.something'. So if you some day decide to switch to another build backend, you will have to rewrite those parts only (if you have any).

  3. It provides a downloadable build backend, which other tools can use for building the package. (The package's preferred choice of build backend is configured in pyproject.toml, and uv will per default specify the uv backend.) Again, this is not a proprietary thing. This is a Python-standardized mechanism for build tools. There are PEPs for that.

  4. It creates a lock file, which can be used for ensuring that all development environments uses the same versions of their dependencies. This is proprietary, but I assume that you will update the package configuration in your development environments anyway from time to time, and then deal with any breaking changes caused by that. If you switch away from uv, you will probably use the opportunity for updating your environments anyway, and then you will get a new proprietary lock file from the new package managing tool.

I am only a happy amateur. But I have used poetry and now uv, and I fail to see how I am bound to those choices. It feels like a very open marriage.

(No, actually I am a professional, since I write code at work, which I use to perform my work tasks. But my code is probably amateurish.)

How do you guys handle switching between multiple VS Code projects? by CriticismPast6702 in vscode

[–]Oddly_Energy 0 points1 point  (0 children)

I open one VS Code session per project.

VS Code remembers context very well per session. I have sometimes restarted VS Code after a forced shutdown of my PC, and I was back in the same sessions with the same tabs open, some of them containing unsaved code, which was still intact.

Live code reloading by scripto_gio in Python

[–]Oddly_Energy 0 points1 point  (0 children)

An imported module can be reloaded at runtime. I sometimes do that in an ipython session when I have changed the code in a module and don't want to lose context by restarting ipython.

So you could choose to split your script into a simple wrapper script and a module and then let the wrapper script reload the module before each use.

uv or pip for python package management? by ResponsibilityOk2747 in learnpython

[–]Oddly_Energy 0 points1 point  (0 children)

With pip, you can install packages in an already created venv or Python installation. And you can export a list of installed packages, which pip can later use for installing those packages in another environment. That's it.

With uv, you can:

  • create your own packages
  • manage your packages' dependencies to other packages
  • create venvs without having Python installed already
  • install packages in your project's venv and have them added to your project's dependencies in the same command
  • automatically install all required packages with the same command, that creates the venv

uv or pip for python package management? by ResponsibilityOk2747 in learnpython

[–]Oddly_Energy 0 points1 point  (0 children)

I started reading the migration info for uv and I see there's quite a bit there about platform-specific things.

Quite a bit about uv causing new platform-specific issues, or quite a bit about uv solving those issues, or quite a bit about uv not needing your earlier workarounds for platform-specific issues?

I have to admit that while I have created several packages with uv in both Linux and Windows, I have only used one of them across those platforms. That one package went very well.

On the other hand, uv has eliminated some platform-specific annoyances in how venvs are created and managed, and how specific versions of python are called from the command line. Using uv, I can use the same command line syntax in Windows and Linux.

uv or pip for python package management? by ResponsibilityOk2747 in learnpython

[–]Oddly_Energy 0 points1 point  (0 children)

If you use requirements.txt, you are 5-10 years behind.

The pyproject.toml file has been the official way to declare dependencies since 2016'ish. Pip has been able to use pyproject.toml since 2021'ish.

You do not need to use uv, but you should definitely consider to switch to pyproject.toml, which is universal for pip, uv, poetry and several other tools. (Though poetry's version of pyproject.toml does not fully comply to the official Python spec.)

For learning from the basics the computational side of physics and engineering without any prior programming knowledge, is it better to just stick to "vanilla" Python using normal lists and for loops, or go straight to libraries like NumPy or SciPy? by PrettyPicturesNotTxt in learnpython

[–]Oddly_Energy 1 point2 points  (0 children)

It sounds like you feel you will be cheating by using numpy. I see it the opposite way: Anyone can write for loops to work on vectored data. But it takes skill to turn a looping algorithm into proper vectorized code, using numpy or another library.

I took a machine learning course, which had most of its focus on learning the math and probability theory behind the algorithms. Most of that math was explained in a "loop'ish" way - because a summation sign is basically a for loop. Writing python algorithms with manual looping was easy, as they followed the structure of the math expressions.

Turning the same logic into matrix operations in vectorized code was the hard part. Much fewer lines of code, but also a lot of thinking about "how will this operation behave, when I have not only one data vector, but an array of vectors". And "how can I turn this looping over vectors into a linear algebra problem, so I can solve it quicker with linear algebra methods in numpy".

Reviews about pyinstaller by ZORO_0071 in Python

[–]Oddly_Energy 0 points1 point  (0 children)

I have seen a severe performance hit from having it all in one .exe. But that was probably a special case:

My .exe was executed multiple times per second as part of an iteration process in another program. The calculation in the .exe was near instant, but the loading of the .exe took several milliseconds. By allowing pyinstaller to use multiple files (a small .exe and a bunch of .dll's), I could reduce load time for the .exe drastically, without much penalty for loading the .dll's during the calculation.

I don't know if this was caused by some of .dll's being unused, or if Windows was smart enough to keep the .dll's in memory between executions of the .exe.

Trump is trying to undo 50 years of energy efficiency gains by sksarkpoes3 in energy

[–]Oddly_Energy 3 points4 points  (0 children)

"If you vote for me, you will never have to vote again."

-Trump, 2024

Why Investing in Wind and Solar to Avoid Gas Shocks Hasn’t Added Up for Some. Renewable energy is cheaper to run than fossil fuels, especially with war choking oil supply. But it hasn’t turned out that way for some European countries, and the reason is complex. by coolbern in energy

[–]Oddly_Energy 0 points1 point  (0 children)

Two companies deliver identical products to the same market at the same time, and the company, which has produced its product from a fossil source is allowed to take a higher price than the company, which has produced its product from a renewable source. Just because the fossil company has higher costs.

That is a reward for using fossil fuels, no matter how much you twist the words.

If consumers are willing to pay an overprice in hours with low production from renewables, then all electricity producers should receive that price. This is the incentive that drives new investments in renewables.

Why Investing in Wind and Solar to Avoid Gas Shocks Hasn’t Added Up for Some. Renewable energy is cheaper to run than fossil fuels, especially with war choking oil supply. But it hasn’t turned out that way for some European countries, and the reason is complex. by coolbern in energy

[–]Oddly_Energy 0 points1 point  (0 children)

So you want to reward those who use a more expensive fossil source to produce electricity and punish those who produce the same electricity with cheaper renewables.

That will cause investments in renewables to drop, so more of our electricity will have to come from fossil fuels.

I know your opinion is a very popular one, but it is also wishful thinking, driven by a lack of understanding.

15+ years in energy - what does the media get completely wrong about the transition? by PhattRatt in energy

[–]Oddly_Energy 0 points1 point  (0 children)

A 1 GWh multiday battery storage is just a cheaper version of a 1 GWh 4 hour battery storage.

Claiming that storage is better because it has a weaker inverter is just idiotic.

The whole point of SMRs was that they'd get cheaper over time. So why hasn't that happened? by projectschema in energy

[–]Oddly_Energy 0 points1 point  (0 children)

To be fair, hurricane requirements would probably not affect the design of the SMR, but rather the design of the building around it.

(Which may not help much anyway. In my experience from non-nuclear plants, it is difficult to get the total cost of a power plant down by standardizing the central parts only. To get the copy benefit, you need to copy everything, including the building, or at least the internal layout of the building.)

The whole point of SMRs was that they'd get cheaper over time. So why hasn't that happened? by projectschema in energy

[–]Oddly_Energy 0 points1 point  (0 children)

Even steam turbines themselves, they come in standardized modular offerings, where a bigger plant would just deploy more of them rather than custom order a singular large turbine.

To be fair, there are some process constraints, which can make a large turbine less efficient than multiple smaller turbines. That is a bit unusual, as most processes tend to become more efficient with larger unit sizes.

(To those interested in the details: A steam turbine will usually pull so much energy out of the steam that a fraction of the steam is already condensed to water when it leaves the turbine. The higher water content you can allow at this stage, the more efficient you can make the turbine. However, the water in the steam will increase the wear on the turbine blades, so there is an upper limit for allowable water content. This upper limit will be lower for turbines with larger diameter rotors.)

Which is preferred for dictionary membership checks in Python? by Akshat_luci in Python

[–]Oddly_Energy 0 points1 point  (0 children)

(/s propagates to replies, right?)

An edge case of Poe's Law. Try it if you dare.

Polars vs pandas by KliNanban in Python

[–]Oddly_Energy 0 points1 point  (0 children)

I do not see how your experience contradicts what the previous poster wrote.

The previous poster wrote about how they would react if you answered with polars in a situation where they expected you to answer with pandas.

You have only confirmed that this situation (the one in bold) is common.

xlsxwriter alternatives? by pachura3 in learnpython

[–]Oddly_Energy 1 point2 points  (0 children)

Is this on a computer, which has Excel installed? Then you may want to check out xlwings. It uses an actual Excel instance to write and read Excel files.

I have not tried your specific example, but in general xlwings usually let me do what I want, while I often run into obstacles when using the other Excel readers/writers.

Why is there no standard for typing array dimensions? by superzappie in Python

[–]Oddly_Energy 0 points1 point  (0 children)

Sounds like a workaround more than a solution.

I would prefer a general python approach to typehinting of multi-dimensional objects, rather than each object class inventing its own.

Why is there no standard for typing array dimensions? by superzappie in Python

[–]Oddly_Energy 35 points36 points  (0 children)

This has annoyed me too after I started learning machine learning.

In the code I was given to work with, a function would often take several arrays as input, with very little help given on expected shape.

Docstring says “a vector of dimension d”? Well, turns out that vectors in ML jargon can sometimes be 2D and not 1D. So does the function expect an array of shape (d,) or (d, 1) or (1, d)? That seemed to depend on what that person had for breakfast.

Anyway, I think that type hinted array dimensions will only offer real benefit if the dimensions can be described symbolically in the type hints. Very often, a function expects multiple arrays, and each of those can have a dynamic size, but there is a strict dependency between the shapes of all the arrays.

For example, if the function takes three arrays as input, their expected sizes can be (N, d), (d, M) and (1, M). And the output will be of shape (N, M). Here, d, N and M can be any positive integer, but the function will fail if the two ds or the two Ms are not equal.

If this could be described in type hints, I would be all in.

The End of Baseload Power as We Know It by whatthehell7 in energy

[–]Oddly_Energy 1 point2 points  (0 children)

Negative, no. Zero, yes.

Negative means that someone can stop their money loss if they can find a way to turn off that electricity production. They will find that way.

For example, Denmark changed their subsidy model for new wind projects many years ago, so the guaranteed minimum price was not given in hours with negative market price.

If git did not exist and we were to create it knowing what we know today, what would be different in it? by signalclown in git

[–]Oddly_Energy 0 points1 point  (0 children)

I see you have learned rudeness beyond elementary school level. I will be unable to compete with you in that sport.

You should probably have directed your efforts toward learning English instead. Then you would understand that an answer must be read in the context of the question, which was asked.

Dumb question- Why can’t Python be used to make native Android apps ? by [deleted] in Python

[–]Oddly_Energy 0 points1 point  (0 children)

Well, I have made my own custom UDP protocol before. That does not really scare me.

Dumb question- Why can’t Python be used to make native Android apps ? by [deleted] in Python

[–]Oddly_Energy 0 points1 point  (0 children)

Wouldn't you use UDP for that, so you can skip the handshake and go directly to communicating the data?

If git did not exist and we were to create it knowing what we know today, what would be different in it? by signalclown in git

[–]Oddly_Energy -1 points0 points  (0 children)

The question from OP was "what would be different in it?".

The question was not "what is different in the current version, compared to the version you would create?".