Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
maleldil
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
18 ms
·
481.
▲
by
maleldil
1y ago
> nothing about type annotations constrains Python code at all Sorry, but this is just not true. Don't get me wrong, I write typed Python 99% of the time (pyright in strict mode, to be precise), but you can't type check every p
482.
▲
by
maleldil
1y ago
If I understand correctly, defining the protocol like this forces the implementation classes to have the members as proper fields and disallows properties. If you define `diameter` as a property in the protocol, it supports both: from
483.
▲
by
maleldil
1y ago
> As long as those low-level operations are fast, those Python-only algorithms will also be fast. Only if you spend more time on the C implementations than on Python. If you have pure Python loops, you'll be slow. You need quite hig
484.
▲
by
maleldil
1y ago
How big is your screen? At 27", I can clearly see pixels on 1440p. A 4k display with 150% scaling (effectively 1440p) looks much better. Maybe you haven't used a higher resolution? If so, you might not know what you're missin
485.
▲
by
maleldil
1y ago
How many such extreme situations do you encounter in your daily life? Most people will not face situations like these, so "never lie" is reasonable.
486.
▲
by
maleldil
2y ago
Parent's example had a direct `iter(thing)`. Even if you had to use `iter(thing, sentinel)`, you'd still use `for val in iter(thing, sentinel)`, not while.
487.
▲
by
maleldil
2y ago
> it was using decorators to mutate some global state It isn't. The original version was doing that, but the "decorator" one wasn't. The data variable is internal to the closure, so different invocations of the decora
488.
▲
by
maleldil
2y ago
This is about Python decorators: https://docs.python.org/3/glossary.html#term-decorator . In summary, they are functions that return functions, which allow you to wrap their behaviour (e.g. add a cache, transform a func
489.
▲
by
maleldil
2y ago
Yes, please. Given I'm forced to use Python, I'd welcome any "compile time" tools I can get. These days, it's using pyright with strict mode, which is pretty good, but there's still a long way to go.
490.
▲
by
maleldil
2y ago
You can use `if (response := get_user_input()) is not None` if that's important. IME, empty strings and None would be treated the same way.
491.
▲
by
maleldil
2y ago
> Does modern, production-level python code use types everywhere? I don't know about code inside companies, but most new open source projects I encounter use typing. Many old ones have been converted too. > Is duck typing frowned
492.
▲
by
maleldil
2y ago
Isn't this equivalent to just `for val in thing`?
493.
▲
by
maleldil
2y ago
I disagree. First of all, it takes a minute to search "python :=", and the construct itself is pretty simple. It's been part of the language since 2018[0]. I don't think "not knowing the language" is a good rea
494.
▲
by
maleldil
2y ago
> would execute concurrently Iterators are not (necessarily) concurrent. I believe you mean lazily.
495.
▲
by
maleldil
2y ago
I just went to mainland Europe over Easter. The only payment method I ever used was my phone (Google Pay). Not just restaurants, but everything. This matched my observations of other people. I withdrew some Euros just in case, but did not u
496.
▲
by
maleldil
2y ago
Linters complain because f"hello" and "hello" are the _exact_ same string. t"hello" isn't even a string.
497.
▲
by
maleldil
2y ago
That's the whole point. If you build something on top of open source code, your code should be open source too.
498.
▲
by
maleldil
2y ago
This would be fine in an ideal world. However, the one we live in has crawlers that don't care how many resources they use. They're fine with taking the server down or bankrupting the owner as long as they get the data they want.
499.
▲
by
maleldil
2y ago
> Go _is_ something of a sharp tool. Maybe we need to put a warning on it: for mature audiences only This has been said for other languages, and it turns out no one is mature enough to consistently make it work without issues. The world
500.
▲
by
maleldil
2y ago
That's from 3.11 onwards.
501.
▲
by
maleldil
2y ago
What are you advocating for? Zero external dependencies? Write a new YAML parser from scratch? Rolling your own crypto?
502.
▲
by
maleldil
2y ago
It's true that simonw writes a lot about LLMs, but I find his content to be mostly factual. Much of it is positive, but that doesn't mean it's hype.
503.
▲
by
maleldil
2y ago
It's a protocol. You make payments through your bank app. You can make payments directly, basically a bank transfer, or through a QR code.
504.
▲
by
maleldil
2y ago
Codespell works very well, in my experience. I run it from the command line and in CI. https://github.com/codespell-project/codespell
505.
▲
by
maleldil
2y ago
The whole idea is that we need a definition that everyone agrees With. The OSD is what the software community at large agreed, so any licences that claim to be open-source are compared to that.
506.
▲
by
maleldil
2y ago
Please stop forcing your music on everyone around you. Get headphones.
507.
▲
by
maleldil
2y ago
> That was truly foul Is it because, as the leader of a language, he shouldn't be making "attacks" against other languages? Because, as far as V being a fraud, he was 100% correct.
508.
▲
by
maleldil
2y ago
Yes, 100%. I believe that any new Python codebase should embrace typing as much as possible[1], and any JavaScript library should be TypeScript instead. A type system with holes like this is better than no type system. [1] Unfortunately, ma
509.
▲
by
maleldil
2y ago
This seems to work in TypeScript too: class C { i: number | number[]; constructor() { this.i = 0; } foo(): void { this.i = []; } bar(): number { if
510.
▲
by
maleldil
2y ago
If you're always looking at things through that lens, the government can never do anything at all, and you'll be left with "complete freedom" to just die from easily preventable issues. There's absolutely no need to
More ›