Live data from Hacker News

Representing Type Lattices Compactly

bernsteinbear.com

11–20 of 29 posts

Re: Representing Type Lattices Compactly

#12
post #10

Come on man just do duck typing. You are killing me with this stuff. It all reads so technical and long and mathematically academic but it’s just a bit mask. I absolutely hate writing python now because I have to reason about a “list of list of errors” type defined by a teenager and they get mad at me if I don’t then define a new “list of list of errors, or none” type when I manipulate it. You guys are now employed b…

This is not about surface level typing. This is about compiler internals.

Re: Representing Type Lattices Compactly

#13
post #10

Come on man just do duck typing. You are killing me with this stuff. It all reads so technical and long and mathematically academic but it’s just a bit mask. I absolutely hate writing python now because I have to reason about a “list of list of errors” type defined by a teenager and they get mad at me if I don’t then define a new “list of list of errors, or none” type when I manipulate it. You guys are now employed b…

[deleted]

Re: Representing Type Lattices Compactly

#14
post #10

Come on man just do duck typing. You are killing me with this stuff. It all reads so technical and long and mathematically academic but it’s just a bit mask. I absolutely hate writing python now because I have to reason about a “list of list of errors” type defined by a teenager and they get mad at me if I don’t then define a new “list of list of errors, or none” type when I manipulate it. You guys are now employed b…

This is not about surface level typing. This is about compiler internals.

I added a couple of sentences in the intro to clarify.

Re: Representing Type Lattices Compactly

#15
post #10

Come on man just do duck typing. You are killing me with this stuff. It all reads so technical and long and mathematically academic but it’s just a bit mask. I absolutely hate writing python now because I have to reason about a “list of list of errors” type defined by a teenager and they get mad at me if I don’t then define a new “list of list of errors, or none” type when I manipulate it. You guys are now employed b…

>filtered by Python types

lmaooo sub-2σ golem detected

Re: Representing Type Lattices Compactly

#16

wow I guess great minds really do think alike, I did almost the same exact thing a few years ago, but eventually gave up as my type hierarchy grew too complex. You could probably represent a lot more complex relations with similar strategies by adding one or two cleanup instructions to union/intersection operations, but whenever I've tried to do it, my head gets dizzy from all the possibilities. And so far I've been…

One possible trick for unions is to use bloom filters, providing you have some way of hashing types. If you create a bloom filter `Bloom(t1, t2)`, it's the same as doing `Bloom(t1) | Bloom(t2)`, where `|` is just bitwise-OR.

Obviously not perfect as it can produce false positives, but if we keep a filter of sufficient size, this will be low, and still be more space-efficient than keeping a bit per type in a large type hierarchy.

Intersections can also be done, but with a potentially higher false-positive rate. The result of `Bloom(t1, t2)` has at least the bits set by `Bloom(t1) & Bloom(t2)`.

Re: Representing Type Lattices Compactly

#18
post #16

wow I guess great minds really do think alike, I did almost the same exact thing a few years ago, but eventually gave up as my type hierarchy grew too complex. You could probably represent a lot more complex relations with similar strategies by adding one or two cleanup instructions to union/intersection operations, but whenever I've tried to do it, my head gets dizzy from all the possibilities. And so far I've been…

One possible trick for unions is to use bloom filters, providing you have some way of hashing types. If you create a bloom filter `Bloom(t1, t2)`, it's the same as doing `Bloom(t1) | Bloom(t2)`, where `|` is just bitwise-OR. Obviously not perfect as it can produce false positives, but if we keep a filter of sufficient size, this will be low, and still be more space-efficient than keeping a bit per type in a large typ…

I don't think space is going to be the first issue that causes this to fall. It will probably be the human mind's ability to conceptualize the space.

Re: Representing Type Lattices Compactly

#20
post #10

Come on man just do duck typing. You are killing me with this stuff. It all reads so technical and long and mathematically academic but it’s just a bit mask. I absolutely hate writing python now because I have to reason about a “list of list of errors” type defined by a teenager and they get mad at me if I don’t then define a new “list of list of errors, or none” type when I manipulate it. You guys are now employed b…

I don't think there will be a movement away from type hints in python any time soon, they're too useful as guardrails for an LLM. But even without using an LLM I'm definitely faster with type hints enforced because I can just sort of feel around with autocomplete. Sure, the transition sucks, but once you're there the benefits start stacking up pretty fast.
Post reply on HN