Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
pansa2
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
54 ms
·
781.
▲
by
pansa2
6y ago
> The Python steering council has, after some discussion, accepted the controversial proposal to add a pattern-matching primitive to the language. Controversial is correct. A poll showed a majority (65%) of core developers opposed to
782.
▲
by
pansa2
6y ago
Python `match` statements do not introduce a new scope. The second example does indeed change the value of `not_found`.
783.
▲
by
pansa2
6y ago
IIRC one of Guido’s reasons for switching to a PEG parser was to enable the addition of pattern matching.
784.
▲
by
pansa2
6y ago
IMO the match statement has some very unintuitive behaviour: match status: case 404: return "Not found" not_found = 404 match status: case not_found: return "Not found&qu
785.
▲
by
pansa2
6y ago
> I'm not sure if you can read the 'accept 634 + another' options as opposed to 'accept 634' However, I’d say that “accept 634 + another” is clearly opposed to “accept 634 & reject both others”, which is th
786.
▲
by
pansa2
6y ago
Is it still the case that these two pieces of code have different behaviour? match status: case 404: return "Not found" not_found = 404 match status: case not_found: return &q
787.
▲
by
pansa2
6y ago
It's interesting that pattern matching has been accepted despite a poll showing a majority (65%) of core developers opposed to this particular proposal, and a plurality (44%) opposed to pattern matching altogether. https://d
788.
▲
by
pansa2
6y ago
It's interesting that pattern matching has been accepted despite a poll showing a majority (65%) of core developers opposed to this particular proposal, and a plurality (44%) opposed to pattern matching altogether. https://d
789.
▲
Python Steering Council Accepts Pattern Matching PEPs for Python 3.10
(mail.python.org)
8 points
by
pansa2
6y ago
|
2 comments
790.
▲
by
pansa2
6y ago
Sounds like it’s similar to how LuaJIT works [0], using a machine-code handler for each VM opcode. AFAICT LuaJIT also uses a templating system to build these, except it generates them at compile-time instead of at run-time. I assume that’s
791.
▲
by
pansa2
6y ago
That sounds more like an advantage of a template compiler , not a template interpreter?
792.
▲
by
pansa2
6y ago
I’m afraid I don’t know the details. However, this post seems relevant - someone who worked on the JIT at Dropbox describes how expensive function calls in CPython can be: https://blog.kevmod.com/2020/05/python-per
793.
▲
by
pansa2
6y ago
Thanks. Is there a performance advantage to the template approach - compared to writing the handler for each opcode directly in assembly language? Or is it just easier to implement?
794.
▲
by
pansa2
6y ago
In Python, “Inline caching has been a huge success” [0]. I believe quickening has been proposed as part of a plan for further speed improvements [1]. [0] https://mobile.twitter.com/raymondh/status/13574784866470051
795.
▲
by
pansa2
6y ago
> improvements that could be made [...] Make a template interpreter like in the JVM. This will allow your specialized opcodes to directly make use of the call stack. What is a “template interpreter”? How does it differ from a normal by
796.
▲
by
pansa2
6y ago
That’s not a bad suggestion, but it’s quite verbose (it would require declaring multiple variables as `var x, var y, var z` instead of `var x, y, z`).
797.
▲
by
pansa2
6y ago
The justification for function-scope instead of block-scope is that only the former really works if you have implicit variable declarations. In turn, implicit variable declarations (using the same syntax for initialisation and assignment) a
798.
▲
by
pansa2
6y ago
That’s exactly the feature that’s causing the problem in this article.
799.
▲
by
pansa2
6y ago
I would never comment that such a function takes a `List of List of Int` - I would instead describe `points` as being something like an `Iterable of Pairs of Numbers`. Are Python type hints able to specify types like that?
800.
▲
by
pansa2
6y ago
That Python can be described by an LL(1) grammar is frequently mentioned in discussions, but I don't know if it's formally documented anywhere. More specifically, the grammar [0] is in EBNF form and is ELL(1). That means that if e
801.
▲
by
pansa2
6y ago
I don't think any single language will be the "next Python" for everybody. Many seem to be happy replacing Python with Go, to get better performance, parallelism and packaging support. However, for my uses I'd much rathe
802.
▲
by
pansa2
6y ago
How to write idiomatic Python? This talk is often recommended: https://www.youtube.com/watch?v=wf-BqAjZb8M
803.
▲
by
pansa2
6y ago
Python is great if you’re writing code to run on your own computer(s). But it’s terrible for packaging into executables to give to others (compared to Go), for embedding in applications (compared to Lua) and for running in the browser (comp
804.
▲
by
pansa2
6y ago
`str.format` can’t be removed completely - it’s necessary if you want to build format strings at runtime. But otherwise, yes - make f-strings the “one obvious way to do it” and use `format` only when necessary. And get rid of the old %-form
805.
▲
by
pansa2
6y ago
Jython and IronPython can work without a GIL more easily than CPython because they don’t support native (C-based) extension modules. Does RustPython intend to support existing Python extensions written in C?
806.
▲
by
pansa2
6y ago
> LALRPOP in fact uses LR(1) by default (though you can opt for LALR(1)), and really I hope to eventually move to something general that can handle all CFGs (like GLL, GLR, LL(*), etc). Seems overkill for a language whose grammar is LL
807.
▲
by
pansa2
6y ago
> Why not just use a different language? I’ve asked myself this question (in a different context) and have concluded that, in general, developers are incredibly resistant to learning and using new languages. For example: if they weren’
808.
▲
by
pansa2
6y ago
I think this represents a difference in philosophy. I want to write functions once and use them wherever suitable, not write separate functions like twice_int, twice_string etc.
809.
▲
by
pansa2
6y ago
> I still can’t quite figure out why type hinting is such a sought after feature. Same here. The arguments for it seem to be: - It allows you to find bugs in your code without running it. I’ve concluded that my workflow must be differe
810.
▲
by
pansa2
6y ago
Without parentheses, it won’t print anything.
More ›