frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Bought myself an Ampere Altra system

https://marcin.juszkiewicz.com.pl/2025/06/27/bought-myself-an-ampere-altra-system/
137•pabs3•5h ago•38 comments

Gridfinity: The modular, open-source grid storage system

https://gridfinity.xyz/
130•nateb2022•6h ago•47 comments

LetsEncrypt – Expiration Notification Service Has Ended

https://letsencrypt.org/2025/06/26/expiration-notification-service-has-ended/
77•zdw•4h ago•37 comments

Cross-Compiling Common Lisp for Windows

https://www.fosskers.ca/en/blog/cl-windows
19•todsacerdoti•2d ago•0 comments

I made my VM think it has a CPU fan

https://wbenny.github.io/2025/06/29/i-made-my-vm-think-it-has-a-cpu-fan.html
536•todsacerdoti•19h ago•131 comments

The Book of Shaders (2015)

https://thebookofshaders.com/
139•max_•3d ago•20 comments

Ask HN: What Are You Working On? (June 2025)

192•david927•13h ago•609 comments

NativeJIT: A C++ expression –> x64 JIT

https://github.com/BitFunnel/NativeJIT
46•nateb2022•6h ago•14 comments

Want to meet people, try charging them for it?

https://notes.eatonphil.com/2025-06-28-want-to-meet-people-charge-them.html
78•ArneVogel•3h ago•30 comments

Cell Towers Can Double as Cheap Radar Systems for Ports and Harbors (2014)

https://spectrum.ieee.org/cell-tower-signals-can-improve-port-security
91•transpute•11h ago•40 comments

Amber insect fossils reveal "zombie" fungi likely lived alongside dinosaurs

https://www.cnn.com/2025/06/24/science/amber-insect-zombie-fungi-fossil
39•jackgavigan•3d ago•14 comments

Revisiting Knuth's "Premature Optimization" Paper

https://probablydance.com/2025/06/19/revisiting-knuths-premature-optimization-paper/
128•signa11•3d ago•61 comments

Ultrasound toothbrush promises painless checks for hidden gum problems

https://phys.org/news/2025-06-ultrasound-toothbrush-painless-hidden-gum.html
27•PaulHoule•3d ago•10 comments

Jane Austen's Boldest Novel Is Also Her Least Understood

https://www.nytimes.com/2025/06/27/books/review/jane-austen-mansfield-park.html
32•lermontov•2d ago•6 comments

The $25k car is going extinct?

https://media.hubspot.com/why-the-25000-car-is-going-extinct
171•pseudolus•17h ago•371 comments

Thousands in Norway told they had won life-changing sums in lottery error

https://www.theguardian.com/world/2025/jun/29/thousands-in-norway-told-they-had-won-life-changing-sums-in-lottery-error
17•zqna•54m ago•18 comments

New Proof Dramatically Compresses Space Needed for Computation

https://www.scientificamerican.com/article/new-proof-dramatically-compresses-space-needed-for-computation/
12•baruchel•2d ago•2 comments

Does Form Shape Function?

https://www.quantamagazine.org/does-form-really-shape-function-20250612/
4•lentoutcry•2d ago•0 comments

LLM's Illusion of Alignment

https://www.systemicmisalignment.com/
40•GodotX•7h ago•26 comments

Use keyword-only arguments in Python dataclasses

https://chipx86.blog/2025/06/29/tip-use-keyword-only-arguments-in-python-dataclasses/
52•Bogdanp•8h ago•19 comments

Touching the back wall of the Apple store

https://blog.lauramichet.com/touching-the-back-wall-of-the-apple-store/
165•nivethan•3d ago•126 comments

4-10x faster in-process pub/sub for Go

https://github.com/kelindar/event
144•kelindar•18h ago•29 comments

Anticheat Update Tracking

https://not-matthias.github.io/posts/anticheat-update-tracking/
54•not-matthias•12h ago•18 comments

Building untrusted container images safely at scale

https://depot.dev/blog/container-security-at-scale-building-untrusted-images-safely
16•Telstrom90•3d ago•7 comments

To the Postbox

https://literaryreview.co.uk/to-the-postbox
5•Caiero•2d ago•0 comments

The Medley Interlisp Project: Reviving a Historical Software System [pdf]

https://interlisp.org/documentation/young-ccece2025.pdf
98•pamoroso•18h ago•10 comments

Many ransomware strains will abort if they detect a Russian keyboard installed (2021)

https://krebsonsecurity.com/2021/05/try-this-one-weird-trick-russian-hackers-hate/
286•air7•15h ago•155 comments

We accidentally solved robotics by watching 1M hours of YouTube

https://ksagar.bearblog.dev/vjepa/
155•alexcos•17h ago•120 comments

Finding a former Australian prime minister’s passport number on Instagram (2020)

https://mango.pdf.zone/finding-former-australian-prime-minister-tony-abbotts-passport-number-on-instagram/
126•guiambros•11h ago•48 comments

Nearly 20% of cancer drugs defective in four African nations

https://www.dw.com/en/nearly-20-of-cancer-drugs-defective-in-4-african-nations/a-73062221
118•woldemariam•10h ago•60 comments
Open in hackernews

Use keyword-only arguments in Python dataclasses

https://chipx86.blog/2025/06/29/tip-use-keyword-only-arguments-in-python-dataclasses/
52•Bogdanp•8h ago

Comments

flakes•5h ago
You could argue the same thing (forcing kwargs) for all Python functions/methods, although, that would make using your APIs very annoying. The `__init__` method for dataclasses are just another method like any other.

As a general rule of thumb, I only start forcing kwargs once I'm looking at above 4-5 arguments, or if the arguments are similar enough that forcing kwargs makes the calling code more readable. For a small number of distinct arguments, forcing kwargs as a blanket rule makes the code verbose for little gain IMO.

masklinn•4h ago
> You could argue the same thing (forcing kwargs) for all Python functions/methods, although, that would make using your APIs very annoying. The `__init__` method for dataclasses are just another method like any other.

While that is self evident at a technical level, it is not quite so from a clarity / documentary perspective: “normal” functions and methods can often hint at their parameters through their naming but it is uncommon for types, for which the composite tends to be much more of an implementation detail.

Of course neither rule is universal e.g. the composite is of prime importance for newtypes, and indeed they often use tuple-style types or have special support with no member names.

vbezhenar•2h ago
> that would make using your APIs very annoying

For Objective C, using named parameters is the only way to call methods. I don't think I read many critique about this particular aspect. IMO it's actually a good thing and increases readability quite a bit.

For JavaScript/TypeScript React codebase, using objects as a poor man's named parameters also very popular approach.

Also I'd like to add, that it seems a recent trend to add feature to IDEs, where it'll add hint for every parameter, somewhat simulating named parameters. So when you write `mymethod(value)`, it'll display it as `mymethod(param:value)`.

So may be not very annoying.

The only little thing I'd like to borrow from JavaScript is using "shortcut", so you could replace `x=x` with `x`, if your local variable happened to have the same name, as parameter name (which happens often enough).

laserlight•36m ago
To be pedantic, Objective-C doesn't have named parameters. Method names are composed of multiple parts, each corresponding to a parameter. Such design contributes to the method's readability and memorability. In contrast, Python methods have their own names, and parameter names are chosen as an afterthought. While there's no reason why Python methods couldn't be named in accordance with parameter names, unfortunately it hasn't been a part of Python's culture.
joshdavham•4h ago
> Positional arguments means a caller can use MyDataClass(1, 'foo', False), and if you remove/reorder any of these arguments, you’ll break those callers unexpectedly. By forcing callers to use MyDataClass(x=1, y='foo', z=False), you remove this risk.

This is an awesome way to prevent future breaking changes!

...but unfortunately, adding this to an existing project would also likely result in breakings changes haha

chipx86•3h ago
That's always the challenge when iterating on interfaces that other people depend on.

What we do is go through a deprecation phase. Our process is:

* We provide compatibility with the old signature for 2 major releases.

* We document the change and the timeline clearly in the docstring.

* The function gets decorated with a helper that checks the call, and if any keyword-only arguments are provided as positional, it warns and converts them to keyword-only.

* After 2 major releases, we move fully to the new signature.

We buit a Python library called housekeeping (https://github.com/beanbaginc/housekeeping) to help with this. One of the things it contains is a decorator called `@deprecate_non_keyword_only_args`, which takes a deprecation warning class and a function using the signature we're moving to. That decorator handles the check logic and generates a suitable, consistent deprecation message.

That normally looks like:

    @deprecate_non_keyword_only_args(MyDeprecationWarning)
    def my_func(*, a, b, c):
        ...
But this is a bit more tricky with dataclasses, since `__init__()` is generated automatically. Fortunately, it can be patched after the fact. A bit less clean, but doable.

So here's how we'd handle this case with dataclasses:

    from dataclasses import dataclass
    
    from housekeeping import BaseRemovedInWarning, deprecate_non_keyword_only_args
    
    
    class RemovedInMyProject20Warning(BaseRemovedInWarning):
        product = 'MyProject'
        version = '2.0'
    
    
    @dataclass(kw_only=True)
    class MyDataclass:
        a: int
        b: int
        c: str
    
    MyDataclass.__init__ = deprecate_non_keyword_only_args(
        RemovedInMyProject20Warning
    )(MyDataclass.__init__)

Call it with some positional arguments:

    dc = MyDataclass(1, 2, c='hi')

and you'd get:

    testdataclass.py:26: RemovedInMyProject20Warning: Positional arguments `a`, `b` must be passed as keyword arguments when calling `__main__.MyDataclass.__init__()`. Passing as positional arguments will be required in MyProject 2.0.
      dc = MyDataclass(1, 2, c='hi')

We'll probably add explicit dataclass support to this soon, since we're starting to move to kw_only=True for dataclasses.
codethief•2h ago
Shouldn't you also be able to patch MyDataclass in a class decorator (on top of/after @dataclass)?
chipx86•2h ago
Yeah, that's the approach we'll be taking in housekeeping. I didn't want to complicate the example any more than I already did :)
FridgeSeal•2h ago
Oh man, the aws Boto3 library does this for a huge number of calls, and it’s awful.

“What parameters does this take?” you ask, “why, it takes ‘kwargs’” responds the docs and your IDE.

How incredibly helpful!

chipx86•2h ago
That's annoying for sure. Though a different problem.

All the kw_only=True argument for dataclasses does is require that you pass any fields you want to provide as keyword arguments instead of positional arguments when instantiating a dataclass. So:

    obj = MyDataclass(a=1, b=2, c=3)
Instead of:

    obj = MyDataclass(1, 2, 3)  # This would be an error with kw_only=True
The problem you're describing in boto3 (and a lot of other API bindings, and a lot of more layered Python code) is that methods often take in **kwargs and pass them down to a common function that's handling them. From the caller's perspective, **kwargs is a black box with no details on what's in there. Without a docstring or an understanding of the call chain, it's not helpful.

Python sort of has a fix for this now, which is to use a TypedDict to define all the possible values in the **kwargs, like so:

    from typing import TypedDict, Unpack


    class MyFuncKwargs(TypedDict):
        arg1: str
        arg2: str
        arg3: int | None


    def my_outer_func(
        **kwargs: Unpack[MyFuncKwargs],
    ) -> None:
        _my_inner_func(**kwargs)


    def _my_inner_func(
        *,
        arg1: str,
        arg2: str,
        arg3: int | None,
    ) -> None:
        ...
By defining a TypedDict and typing **kwargs, the IDE and docs can do a better job of showing what arguments the function really takes, and validating them.

Also useful when the function is just a wrapper around serializing **kwargs to JSON for an API, or something.

But this feature is far from free to use. The more functions you have, the more of these you need to create and maintain.

Ideally, a function could type **kwargs as something like:

    def my_outer_func(
        **kwargs: KwargsOf[_my_inner_func],
    ) -> None:
        ...
And then the IDEs and other tooling can just reference that function. This would help make the problem go away for many of the cases where **kwargs is used and passed around.
DanielVZ•2h ago
In boto3 it helps to add a stubs package for development (and type checking).
ayhanfuat•1h ago
I like keyword-only arguments, but they become tedious too quickly - especially when the variable names already match (fn(x=x, y=y, z=z)). I wish Python had JavaScript’s shorthand property syntax. (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...).
sweetgiorni•1h ago
Python 3.14 adds that shorthand, but with a slight different (and IMO uglier) syntax:

  fn(x=,y=,z=)
https://peps.python.org/pep-0736/

edit: nevermind, that PEP was rejected :/

pansa2•1h ago
That PEP says “rejected”
dgan•53m ago
there should definitely be an ocaml-like equivalent of "~argument"
joshdavham•1h ago
Are there other ways to get this argument-enforcing behaviour in functions, not just data classes?
pansa2•1h ago
Keyword-only arguments? Yes:

https://peps.python.org/pep-3102/

More recently, Python also added support for positional-only parameters:

https://peps.python.org/pep-0570/

est•1h ago
the problem with python dataclasses is I cannot store extra key-values. I can not directly pass any dict to a dataclass but have to choose only supported keys.
meander_water•29m ago
You can also explicitly specify which arguments need to be keyword only using the KW_ONLY sentinel type annotation:

  from dataclasses import KW_ONLY

  @dataclass
  class Point:
      x: float
      _: KW_ONLY
      y: float
      z: float

  p = Point(0, y=1.5, z=2.0)