HNHacker News
TopNewBestAskShowJobs

BerislavLopac

32,006 karma · joined July 21, 2008

submissionscomments
BerislavLopac··on Stelvio: Serverless AWS for Python Devs
There is also Mangum [0], which can wrap up any ASGI app and deploy it as a lambda.

[0] https://mangum.fastapiexpert.com/

BerislavLopac··on uv downloads overtake Poetry for Wagtail users
As much as I am glad that it looks like one solution is being more and more accepted as the golden standard, I'm a little disappointed that PDM [0] -- which has been offering pretty much everything uv does for quite some time now -- has been completely overlooked. :(

[0] https://pdm-project.org

BerislavLopac··on Why do transit agencies keep falling for the hydrogen bus myth?
BMW i3 and Chevrolet Volt both had that option: https://en.wikipedia.org/wiki/Range_extender

And of course, there are plug-in hybrids: https://en.wikipedia.org/wiki/Plug-in_hybrid

BerislavLopac··on Why “alias” is my last resort for aliases
I was nearly 10 years old (i.e. as a Fish user) when I learned about abbr. I used to use functions for everything. :facepalm:
BerislavLopac··on Linux laptop maker called me a Zombie
Yep, I've wanted to explore this route for a while. I had some issues with Linux on Lenovo Legions, so this might be a nice way to keep using both OSs.
BerislavLopac··on We don't need startups, we need Digital-Mittelstand
> Profitable and valuable are synonymous.

So your police, firefighters, the military, health services (not in the US though) and various charities are not valuable? That is an interesting take.

BerislavLopac··on Obscure islands I find interesting
One of my favourites is missing from the list: https://en.wikipedia.org/wiki/Deception_Island
BerislavLopac··on How I use LLMs as a staff engineer
In my mind, this dilemma is actually very simple:

First, what LLMs/GenAI do is automated code generation, plain and simple. We've had code generation for a very long time; heck, even compiling is automated generation of code.

What is new with LLM code generation is non-deterministic, unlike traditional code generation tools; like a box of chocolates, you never know what you're going to get.

So, as long as you have tools and mechanisms to make that non-determinism irrelevant, using LLMs to write code is not a problem at all. In fact, guess what? Hand-coding is also non-deterministic, so we already have plenty of those in place: automated tests, code reviews etc.

BerislavLopac··on Ruff: Python linter and code formatter written in Rust
https://docs.astral.sh/ruff/formatter/black/
BerislavLopac··on Ask HN: Which RSS reader do you use?
https://www.netvibes.com
BerislavLopac··on LLM based agents as Dungeon Masters
Try Tales from the Loop -- https://freeleaguepublishing.com/games/tales-from-the-loop-r...
BerislavLopac··on Germany Opened Its Doors to Migrants. Now It's Struggling to Cope
Ah OK, I had a different definition of "modern times" in mind. But if we use that version, "before modern times" Germany (or its equivalent at the time) was generally a net exporter of emigration.
BerislavLopac··on Germany Opened Its Doors to Migrants. Now It's Struggling to Cope
Except for Turkey, the no. 1 source of immigration to Germany, which is very much in Asia.
BerislavLopac··on Show HN: HackerNews-new-jobs – insights into fresh and recurring job ads
Interest rates were raised from nearly zero, where they were for a number of years. When the interest rates are that low, high-risk investments like VC are more attractive then alternative (having a low chance of high returns is better than guaranteed no returns at all).
BerislavLopac··on Show HN: HackerNews-new-jobs – insights into fresh and recurring job ads
This is nice, but I find this one more detailed: https://hnhiring.com/trends
BerislavLopac··on Mise: Dev tools, env vars, task runner
> it was a rhetorical question

The only case where this question is rhetorical is when you do not really use Python enough to require deciding which management tool to use. Which tells me everything I need to know about you.

BerislavLopac··on Mise: Dev tools, env vars, task runner
> Which one should one use?

Well, that heavily depends on what you want to do. Python has a number of concerns when it comes to code and package management, some of which are not present in most other languages. Here's an incomplete list, off the top of my head:

1. installation and management of installed packages

2. management of Python versions present in an environment

3. management of virtual environments (Python version + packages installed and ready to use, in an isolated context)

4. building of distribution packages (nowadays pretty much only wheels, with or without native extensions, which depend on the target platform)

5. publishing of distribution packages (to PyPI or a compatible repo)

6. defining repeatable deployment environments (a subset of #1)

Most developers face some combination of above problems, and various tools offer solutions for certain combinations -- with a few covering all of them, to different levels of quality. It is crucial to understand your needs and select the tool(s) that offer the right solutions in the way that fits your usual workflow the best.

This article [0] is a good starting point to understanding the current Python packaging landscape, with a clear overview of which problem is covered by which tool.

[0] https://alpopkes.com/posts/python/packaging_tools/

BerislavLopac··on Mise: Dev tools, env vars, task runner
Pipenv is certainly not "officially recommended", and it should be avoided at all costs: https://chriswarrick.com/blog/2018/07/17/pipenv-promises-a-l...
BerislavLopac··on Egoless Engineering
I believe that the GP's point was that different roles have different tools in the box that are more efficient in their particular areas, and tend to rely on these rules even when solving problems in other areas.

It is very common to see engineers trying to solve non-engineering problems using the "technical ingenuity" to attempt resolving social issues; sometimes it works well enough (e.g. timezones), and sometimes it fails pretty miserably (e.g. OLPC).

BerislavLopac··on Egoless Engineering
Fred Brooks never said that adding more developers does not help -- he was stating that solving the single problem of being late will only be exacerbated by adding more people.

To use the infamous analogy that "nine women can't make a child in one month": it is still true, but if your goal is to have more children (as opposed to having one child be born sooner), adding more women would certainly help.

BerislavLopac··on Htmy – Async, pure-Python rendering engine
> Async is syntactic sugar that can be reduced to sync code with callbacks

The whole point of introducing async was to get away from callback hell.

BerislavLopac··on Pex: A tool for generating .pex (Python EXecutable) files, lock files and venvs
I've always been curious why Nim never took off as the solution for use cases like this. It combines the simplicity and clarity of Python-like syntax with the performance of a natively compiled language, which looks like the best of both worlds.
BerislavLopac··on The Product-Market Fit Scale
I always found it very simple to define: when a product has a market (i.e. a group of potential customers) that is willing to pay for it enough (cumulatively) to support a growing business.
BerislavLopac··on Cheaper to rent in Barcelona and commute to London
Considering this was before September 1999, the airport wait times were also much shorter, making this more viable. These days, getting to the airport less than 90 minutes before the flight is cutting it pretty close.
BerislavLopac··on The Dual Nature of Events in Event-Driven Architecture
> I think that's the core of event-driven architecture that events drive the process, i.e. will trigger certain actions.

In an event-driven system, there is neither guarantee not expectation that an event will trigger an action; it might, but it might not. Events are simply a log [0] of "things" happening in various subsystems, published to various channels for other subsystems to ignore or act upon on their own terms.

Let say that we have two subsystems - A and B. When something happens on A, it will emit a corresponding event (e.g. SomethingHappened) to a specific channel (e.g. EventsFromA); if B is listening to that channel, it can "recognise" that event and initiate (i.e. "trigger") some action of its own.

However, if A explicitly wants B to do something, it's a command, i.e. a direct coupling by definition. As GP states, that is better handled as a direct request from A to B.

Theoretically, there is a possible scenario where A "knows" that a certain action needs to happen in the system, but does not know which subsystem has that capability, i.e. has no knowledge that B can do that. In that case it can "request" something to happen, e.g. by submitting an event like "UserCreationRequested"; however, there is no guarantee that any service will "see" that event and act upon it.

[0] https://engineering.linkedin.com/distributed-systems/log-wha...

BerislavLopac··on Ternary Operators
Well, I suppose that's one of the definitions; Hillel opted for the other one. :shrug:

I think that he wanted to emphasize the distinction between operators and functions; in your definition, there is no difference between "binary operator" and "function with two arguments". Of course, some languages limit what characters can be used in function names, but that is certainly not universally true.

BerislavLopac··on State of Python 3.13 performance: Free-threading
> In a poetry lock file transitive dependencies are automatically locked and thereby pinned

That is true for all formats of lock files, by definition.

BerislavLopac··on State of Python 3.13 performance: Free-threading
Yes and no.

There are different types of dependencies, and there are different rules for them, but here's an overview of the best practices:

1. For applications, scripts and services (i.e. "executable code"), during development, pin your direct dependencies; ideally to the current major or minor version, depending how much you trust their their authors to follow SemVer. Also make sure you regularly update and retest the versions to make sure you don't miss any critical updates.

You should not explicitly pin your transitive dependencies, i.e. the dependencies of your direct dependencies -- at least unless you know specifically that certain versions will break your app (and even then it is better to provide a range than a single version).

2. For production builds of the above, lock each of your dependencies (including the transitive ones) to specific version and source. It is not really viable to do it by hand, but most packaging tools -- pip, Poetry, PDM, uv... -- will happily do that automatically for you. Unfortunately, Python still doesn't have a standard lock format, so most tools provide their own lock file; the closest thing to a standard we have at the moment is pip's requirements file [0].

Besides pinned versions, a lock file will also include the source where the packages are to be retrieved from (pip's requirements file may omit it, but it's then implicitly assumed to be PyPI); it can (and should, really) also provide hashes for the given packages, strengthening the confidence that you're downloading the correct packages.

3. Finally, when developing libraries (i.e. "redistributable code"), you should never pin your dependencies at all -- or, at most, you can specify the minimum versions that you know that work and have tested against. That is because you have no control over the environment the code will eventually be used and executed in, and arbitrary limitations like that might (and often will) prevent your users to update some other crucial dependency.

Of course, the above does not apply if you know that a certain version range will break your code. It that case you should most definitely exclude it from your specification -- but you should also update your code as soon as possible. Libraries should also clearly specify which versions of Python they support, and should be regularly tested against each of those versions; it is also recommended that the minimal supported version is regularly reviewed and increased as new versions of Python get released [1].

For more clarity on abstract vs concrete dependencies, I recommend the great article by Donald Stufft from 2013 [2]; and for understanding why top-binding (i.e. limiting the top version pin) should be avoided there is a lengthy but very detailed analysis by Henry Schreiner [3].

[0] https://pip.pypa.io/en/stable/reference/requirements-file-fo...

[1] https://devguide.python.org/versions/

[2] https://caremad.io/posts/2013/07/setup-vs-requirement/

[3] https://iscinumpy.dev/post/bound-version-constraints/

BerislavLopac··on Ternary Operators
This falls into the third category, "Functions/methods that prefix any number of arguments". That the binary operators "go between" the operands is literally the definition used in the article.
BerislavLopac··on Diagram as Code
> you can share your drawings, and export them as SVG files -- yay! I can version them again

Out of curiosity, does anyone know of a drawing tool -- like Excalidraw, Lucid or Draw.io -- that has the option of exporting diagrams to code, i.e. something like PlantUML or Mermaid?

← PreviousPage 3 of 34Next →