frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

How was the Universal Pictures 1936 opening logo created?

https://movies.stackexchange.com/questions/128020/how-was-the-universal-pictures-1936-opening-logo-created
215•azeemba•4h ago•29 comments

MacBook Pro Insomnia

https://manuel.bernhardt.io/posts/2025-07-24-macbook-pro-insomnia
53•speckx•1h ago•26 comments

Introduction to Computer Music

https://cmtext.com/
159•hecanjog•4h ago•30 comments

I tried Servo, the undercover web browser engine made with Rust

https://www.spacebar.news/servo-undercover-web-browser-engine/
167•robtherobber•4h ago•111 comments

Ursa: A Leaderless, Object Storage–Based Alternative to Kafka

https://streamnative.io/products/ursa
15•netpaladinx•47m ago•2 comments

Zig Profiling on Apple Silicon

https://blog.bugsiki.dev/posts/zig-profilers/
28•signa11•2d ago•2 comments

What is gVisor?

https://blog.yelinaung.com/posts/gvisor/
42•yla92•2h ago•26 comments

Many countries that said no to ChatControl in 2024 are now undecided

https://digitalcourage.social/@echo_pbreyer/114946559233051667
168•nickslaughter02•3h ago•92 comments

Magentic-UI: Towards Human-in-the-Loop Agentic Systems

https://arxiv.org/abs/2507.22358
10•fitzn•53m ago•1 comments

GCP CloudQuarry: Searching for Secrets in Public GCP Images

https://trufflesecurity.com/blog/guest-post-gcp-cloudquarry-searching-for-secrets-in-public-gcp-images
7•mooreds•52m ago•0 comments

Following Up on the Python JIT

https://lwn.net/Articles/1029307/
46•Bogdanp•3d ago•11 comments

GEPA: Reflective prompt evolution can outperform reinforcement learning

https://arxiviq.substack.com/p/gepa-reflective-prompt-evolution
69•che_shr_cat•4h ago•16 comments

Profiling without Source code – how I diagnosed Trackmania stuttering

https://larstofus.com/2025/07/27/profiling-without-source-code-how-i-diagnosed-trackmania-stuttering/
28•ibobev•3d ago•2 comments

Infracost (YC W21) hiring first PM to shift $600B cloud spend to proactive

https://www.ycombinator.com/companies/infracost/jobs/ukwJ299-senior-product-manager
1•akh•3h ago

Sumo – Simulation of Urban Mobility

https://eclipse.dev/sumo/
116•Stevvo•3d ago•19 comments

GenosDB (GDB) – Decentralized P2P Graph Database

https://www.npmjs.com/package/genosdb
16•estebanrfp•2h ago•3 comments

NSW Fair Trading – Dark Patterns

https://www.nsw.gov.au/departments-and-agencies/fair-trading/dark-patterns
12•ColinWright•2h ago•1 comments

Go’s race detector has a mutex blind spot

https://doublefree.dev/go-race-mutex-blindspot/
50•GarethX•2d ago•32 comments

Altima NSX

https://computeradsfromthepast.substack.com/p/altima-nsx
18•rbanffy•3h ago•12 comments

How to trigger a command on Linux when power switches from AC to battery

https://dataswamp.org/~solene/2025-05-31-linux-killswitch-on-power-disconnect.html
44•Mr_Minderbinder•5h ago•19 comments

Nova: A New Web Framework for Erlang

37•taure•2h ago•11 comments

So you're a manager now

https://scottkosman.com/post/blog/so-youre-a-manager-now/
140•mooreds•2h ago•105 comments

Carbon Language: An experimental successor to C++

https://docs.carbon-lang.dev/
5•samuell•1h ago•1 comments

OpenAI's ChatGPT Agent casually clicks through "I am not a robot" verification

https://arstechnica.com/information-technology/2025/07/openais-chatgpt-agent-casually-clicks-through-i-am-not-a-robot-verification-test/
165•joak•2d ago•163 comments

U.S. Senators Introduce New Pirate Site Blocking Bill: Block Beard

https://torrentfreak.com/u-s-senators-introduce-new-pirate-site-blocking-bill-block-beard/
31•HieronymusBosch•53m ago•4 comments

The Math Is Haunted

https://overreacted.io/the-math-is-haunted/
331•danabramov•19h ago•149 comments

Ollama's new app

https://ollama.com/blog/new-app
501•BUFU•18h ago•259 comments

Orion Browser by Kagi

https://kagi.com/orion/
5•gtirloni•1h ago•0 comments

Figma will IPO on July 31

https://www.figma.com/blog/ipo-pricing/
309•nevir•17h ago•202 comments

Benchmarks in CI: Escaping the Cloud Chaos

https://codspeed.io/blog/benchmarks-in-ci-without-noise
12•adriencaccia•3h ago•2 comments
Open in hackernews

A Python dict that can report which keys you did not use

https://www.peterbe.com/plog/a-python-dict-that-can-report-which-keys-you-did-not-use
88•gilad•4d ago

Comments

jraph•4d ago
I did exactly the same thing in our Confluence to XWiki migrator to easily and automatically report which macro parameters we don't handle when converting Confluence macros to equivalent macros in XWiki.

This can be used to evaluate the migration quality and spot what can be improved.

https://github.com/xwiki-contrib/confluence/blob/7a95bf96787...

IshKebab•1d ago
I think if you feel like you need this then it's a bit of a red flag and you should be using Pydantic or `dataclass` instead, then your IDE can statically tell you which fields you don't access (among many other benefits). Dicts are mainly for when you don't know the keys up front.
mb7733•1d ago
Static analysis could only tell you which fields are never used, across all usage of the class. Not on a given instance.
taeric•1d ago
Counterpoint, something like this for dataclasses would also be very useful.

That is, it isn't just knowing whether or not the data is ever used. It is useful to know if it was used in this specific run. And often times, seeing what parts of the data was not used is a good clue as to what went wrong. At the least, you can use it to rule out what code was not hit.

ok123456•1d ago
If you're inheriting from dict to extend its behavior, there are a lot of side effects with that, and it's recommended to use https://docs.python.org/3/library/collections.html#collectio... instead.
quietbritishjim•1d ago
From right above where you linked to:

> The need for this class has been partially supplanted by the ability to subclass directly from dict; however, this class can be easier to work with because the underlying dictionary is accessible as an attribute.

Sounds like (unless you need the dict as a separate data member) this class is a historical artefact. Unless there's some other issue you know of not mentioned in the documentation?

ok123456•1d ago
dict doesn't follow the usual object protocol, and overloaded methods are runtime dependent. It's only guaranteed that non-overloaded methods are resolved least surprisingly.
quietbritishjim•19h ago
I think you mean overridden (i.e. defined in both base class and derived class) rather than overloaded (i.e. defined more than once in a single place but with different argument types, as least from a typing point of view [1]). Your comment seriously confused me till I figured that out.

[1] https://typing.python.org/en/latest/spec/overload.html

Even then, to be honest I'm a bit sceptical. Can you point at a link in the official documentation that says overriding methods of dictionaries may not work? I would have thought the link to UserDict would have mentioned that if true. What do you mean they are "runtime dependent"?

ok123456•43m ago
See Chapter 14 of "Fluent Python", 2nd Edition by Luciano Ramalho. He details this under the heading "Subclassing Built-In Types Is Tricky."

UserDict isn't just some historical artifact of a bygone era like some of the posters below are miscorrecing me on.

mont_tag•23h ago
No, that is not the recommendation. People routinely and reliably inherit from dict.

The UserDict class is mostly defunct and is only still in the standard library because there were a few existing uses that were hard to replace (such as avoiding base class conflicts in multiple inheritance).

smcin•23h ago
UserDict is not formally deprecated but it will be someday, so code that relies on it is not future-proof.
9dev•18h ago
Ah, Python. The language where nobody agrees on the right way to do things, ans just does their own instead. Five ways to describe an object of a certain shape? Six package managers, with incompatible but overlapping ways to publish packages, but half of them without a simple way to update dependencies? Asynchronous versions of everything? Metaprogramming that makes Ruby blush? Yes! All of it! Lovely.
boothby•1d ago
Just a heads up, this fails to track usage of get and setdefault. The ability to iterate over dicts makes the whole question rather murky.
quietbritishjim•1d ago
I didn't know about the setdefault method, and wouldn't have guessed it lets you read a value. Interesting, thanks.

Another way to get data out would be to use the new | operator (i.e. x = {} | y essentially copies dictionary x to y) or the update method or ** unpacking operator (e.g. x = {**y}). But maybe those come under the umbrella of iterating as you mentioned.

notatallshaw•1d ago
setdefault was a go to method before defaultdict was added to the collections module in Python 2.5, which replaced the biggest use case.
boothby•23h ago
It's been some time since I last benchmarked defaultdict but last time I did (circa 3.6 and less?), it was considerably slower than judicious use of setdefault.
quietbritishjim•21h ago
One time that defaultdict may come out ahead is if the default value is expensive to construct and rarely needed:

    d.setdefault(k, computevalue())
defaultdict takes a factory function, so it's only called if the key is not already present:

    d = defaultdict(computevalue)
This applies to some extent even if the default value is just an empty dictionary (as it often is in my experience). You can use dict() as the factory function in that case.

But I have never benchmarked!

masklinn•20h ago
> if the default value is expensive to construct and rarely needed:

I'd say "or" rather than "and": defaultdict has higher overhead to initialise the default (especially if you don't need a function call in the setdefault call) but because it uses a fallback of dict lookup it's essentially free if you get a hit. As a result, either a very high redundancy with a cheap default or a low amount of redundancy with a costly default will have the defaultdict edge out.

For the most extreme case of the former,

    d = {}
    for i in range(N):
        d.setdefault(0, [])
versus

    d = defaultdict(list)
    for i in range(N):
        d[0]
has the defaultdict edge out at N=11 on my machine (561ns for setdefault versus 545 for defaultdict). And that's with a literal list being quite a bit cheaper than a list() call.
hackish•21h ago
Along with those and iteration, it also would need to handle del/pop/popitem/update/copy/or/ror/... some of which might necessitate a decision on whether comparisons/repr also count as access.
rjmill•21h ago
Indeed. Inheriting from 'collections.UserDict' instead of 'dict' will make TFA's code work as intended for most of those edge cases.

UserDict will route '.get', '.setdefault', and even iteration via '.items()' through the '__getitem__' method.

edited to remove "(maybe all?) edge cases". As soon as I posted, I thought of several less common/obvious edge cases.

jgalt212•23h ago
why not inside of __init__

  self.accessed_keys = set()
instead of

    @property
    def accessed_keys(self):
        return self._accessed_keys
Jaxan•21h ago
With the @property you only get the “getter” and not the “setter”.
eurleif•19h ago
But that doesn't accomplish much, because you can still do: `d.accessed_keys.add('foo')`.
Jaxan•8h ago
That’s right
larrik•23h ago
I actually wrote something similar in nodejs for a data import system. Was very handy.
null_deref•23h ago
Interesting! Can you elaborate a little bit more on your implementation?
larrik•22h ago
Mine was a bit more specific. I had a JSON object of data exported per account I was importing, and then a complex mapping (also JSON) of where to put each piece of data.

Therefore, I really wanted to know that I was actually pulling in all of the data I needed, so I tracked what was seen vs not seen, and compared against what was attempted to see.

In the end it was basically a wrapper around the JSON object itself, that allowed lookup of data via a string in "dot notation" (so you could do "keyA.key2" to get the same thing you would have directly in JSON. Then, it would either return a simple value (if there was one), or another instance of the wrapper if the result was itself an object (or an array or wrapped objects). All instances would share the "seen" list.

It's unfortunately locked behind NDA/copyright stuff, but the implementation was only 67 lines.

null_deref•11h ago
Nice very interesting, thank you very much for taking the time to explain a bit further
simon04•23h ago
Very useful. For configparser.ConfigParser I've found https://stackoverflow.com/a/57307141
golly_ned•21h ago
I have a similar use case and this idea also occurred to me.

However: the dict in this case would also include dataclasses, and I’d be interested in finding what exact attributes within those dataclasses were accessed, and also be able to mark all attributes in those dataclasses as accessed if the parent dataclasses is accessed, and with those dataclasses, being config objects, being able to do the same to its own children, so that the topmost dictionary has a tree of all accessed keys.

I couldn’t figure out how to do that, but welcome to ideas.

codethief•20h ago
Only tangentially related but I am really excited about PEP 764¹ (inline typed dictionaries). If it gets accepted, we can finally replace entire hierarchies of dataclasses with simple nested dictionary types and call it a day.

I am currently teaching (typed) Python to a team of Windows sysadmins and it's been incredibly difficult to explain when to use a dataclass, a NamedTuple, a Pydantic model, or a dictionary.

¹) https://peps.python.org/pep-0764/

JohnKemeny•20h ago
Do you seriously have difficulties explaining when to use a class and when to use a dictionary?!
codethief•20h ago
You can create dictionaries on the fly. But dataclass objects require defining that dataclass first. The type safety (and LSP support) story for accessing individual dataclass fields is better than for accessing dict items (sometimes even when they are TypedDicts), but for iterating over all fields it's worse. dataclasses are nominal types and can contain additional logic, TypedDicts are structural ones, overall simpler, can be more convenient and lead to looser coupling. Dataclasses use metaclass and decorator magic while TypedDics are just plain dicts. Etc.

Let me make this more concrete: Those sysadmins frequently need to process and pass around complex (as in heavily nested) structured data. The data often comes in the form of singleton objects, i.e. they are built in single place, then used in another place and then thrown away (or merged into some other structure). In other words, any class hierarchy you build represents boilerplate code you'll only ever use once and which will be annoying to maintain as you refactor your code. Do you pick dataclasses or TypedDicts (or something else) for your map data structures?

In TypeScript you would just use `const data = <heavily nested object> as const` and be done with it.

quietbritishjim•20h ago
The line is seriously blurred.
xg15•19h ago
To be honest, that proposal sounds like it would make the problem even worse, by blurring the line between dicts and dataclasses even more.
codethief•19h ago
How does creating anonymous TypedDicts (and allowing them to be nested on the fly) blur the line "even more" when those features are not supported by dataclasses?

I mean I agree w.r.t. the blurriness in general but this PEP is not going to change anything about that, in neither direction.

xg15•17h ago
True, but I think what I don't like is that this PEP essentially creates an entire new way of "type definitions" that is separate from the type definitions we already have.

I get the rationale for "anonymous strict" return types, but then I think a better way would be to think up some way to accomplish that for dataclasses.

mvieira38•19h ago
When, if ever, do you use TypedDicts?
tiltowait•17h ago
I use them for API responses/requests where dataclasses/pydantic don't add much value and introduce extra function calls and overhead. It's most common when part of the response from one API gets shuttled off to another. There's often no value in initializing a model object, but it's still handy to have some form of type-checking as you construct the next API call.
nurettin•20h ago
AI front: We have models to generate pictures, videos and code. We have the best devs and are so fskin rich!

Rust front: Here's a faster ls called ls-rs with different defaults, you should use this!

Go front: Here's reverse proxy #145728283 it is an open source project that has slightly different parameters than all the others.

Python hobo front: Uhh guys here's a dict that kinda might remember what you've accessed if you used it in a particular way.

mrits•18h ago
For giant dicts a bloomfilter would work great here