Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
ericvsmith
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
7 ms
·
31.
▲
by
ericvsmith
4y ago
> Most US homes actually do receive 240v, it's just done in an unusual biphase configuration with two "hot" phases 180 degrees apart. If you connect a device across the phases it will receive the full 240 volts, which is o
32.
▲
by
ericvsmith
4y ago
I feel the same way. I'd love to use macros to implement dataclasses. But it does open the door for unreadable code. I'm torn on the issue: I don't want to be restricted from improving dataclasses in what would be fairly obvi
33.
▲
by
ericvsmith
4y ago
I don't think you're likely to see zero overhead decorators any more than "zero overhead software" in general. Take dataclasses: it adds a bunch of synthesized methods to a class, and needs to use "exec" to cre
34.
▲
by
ericvsmith
4y ago
I’m contemplating pushing for it in 3.12, but it’s probably more than a year’s worth of work to implement and shepherd the PEP through. So 3.13 is more likely. And I’m not sure it won’t get shot down anyway. It’s a big step for Python.
35.
▲
by
ericvsmith
4y ago
See also PEP 638 – Syntactic Macros https://peps.python.org/pep-0638/
36.
▲
by
ericvsmith
4y ago
Came here to mention unittest.subtest. It's for exactly this case.
37.
▲
by
ericvsmith
4y ago
You’re in luck! https://m.youtube.com/watch?v=FM8uRAdZ8S0 Matt’s videos have come a long way since this one, but I still refer back to it. I just sharpened a carpenter’s pencil with Matt’s method today!
38.
▲
by
ericvsmith
4y ago
This was in early March 2020 (so, just pre-Covid). I was using orders@swissmicros.com, because I was responding to the invoice they sent me. And I self-host my email server. Hope that helps.
39.
▲
by
ericvsmith
4y ago
I had the exact opposite experience. After already owning a DM42, DM41X, and a DM16L, and I bought a DM12L for a client. The screen had several LCD segments that faintly showed as always on. I wrote an email and was contacted by Michael (th
40.
▲
by
ericvsmith
5y ago
dataclasses do not use metaclasses (I’m the dataclasses author).
41.
▲
by
ericvsmith
5y ago
I don't understand your point. Are you saying that `__eq__` shouldn't be implemented at all? There's a switch for that, too.
42.
▲
by
ericvsmith
5y ago
dataclasses makes it easy to just add your own `__eq__` method, if the default doesn't suit you. You just define it! Nothing else is required. So I wouldn't be so quick to abandon dataclasses in such a case.
43.
▲
by
ericvsmith
5y ago
I wouldn't say adding dataclasses was "reactionary". One of the reasons for adding it was to use it in the stdlib itself, which is obviously something we couldn't do with attrs. And because dataclasses skipped ahead to j
44.
▲
by
ericvsmith
5y ago
dataclasses author here. Does the keyword-only feature in 3.10 help you at all?
45.
▲
by
ericvsmith
5y ago
dataclasses author here. That's not true. You can use make_dataclass the same way you can use namedtuple: >>> from dataclasses import make_dataclass >>> A = make_dataclass("A", ["x", "y&
46.
▲
by
ericvsmith
5y ago
nuitka is at https://nuitka.net/
47.
▲
by
ericvsmith
5y ago
I find that hard to believe, but I'm willing to be wrong. My Apple TV HD is in a cabinet with solid sides and doors (3/4" MDF). The television is wall mounted above it, outside the cabinet, and maybe 12" behind the Apple
48.
▲
by
ericvsmith
6y ago
You'd be better off using "...".format_map(your_dict). This case is exactly why it exists.
49.
▲
by
ericvsmith
6y ago
f-strings are so much faster that I've seen an increase in speed over %-formatting for logging. If there's even a 10% chance that a string will be actually logged (and therefore %-formatting will take place), I'll replace it
50.
▲
by
ericvsmith
6y ago
Executing user-provided code isn't possible. f-strings must be literals, so there's no user-defined strings involved. You could of course eval something the user provided, but there's no more of a risk with f-strings than the
51.
▲
by
ericvsmith
6y ago
The more efficient version of this is .format_map(locals())
52.
▲
by
ericvsmith
6y ago
There would be a __future__ import to turn it on, at least for some number of releases. But yeah, I'm not sure it should ever be the default behavior. It makes most sense to me as a per-module opt-in, but then a __future__ import doesn
53.
▲
by
ericvsmith
6y ago
I've put together a proposal to have all strings be f-strings by default. Then you could drop the "f" prefix. I also propose adding a "p" prefix (for "plain") to remove the f-string parsing behavior. I tal
54.
▲
by
ericvsmith
6y ago
This is because of how f-strings were initially implemented: I piggy-backed them off of "regular" strings, then post-parsed inside that string. But the restriction is that the entire f-string (after the f) needs to be a valid regu
55.
▲
by
ericvsmith
6y ago
Yes, attrs is the spiritual parent of dataclasses, including the decision to not use metaclasses. Thanks for mentioning this: I try to always give credit to Hynek and attrs.
56.
▲
by
ericvsmith
6y ago
Maybe that would have worked better with a metaclass. But still, I think not using a metaclass is the more flexible design. Maybe I'll add the "add_slots" behavior into the @dataclass decorator in 3.10, even though it would n
57.
▲
by
ericvsmith
6y ago
I have a decorator to add support for slots: https://github.com/ericvsmith/dataclasses/blob/master/datacl... (although I'll admit I haven't tested it in a while). The reason it's not an op
58.
▲
by
ericvsmith
6y ago
Author of dataclasses here. > (Example - enums are implemented with a metaclass and dataclasses with a class decorator - arguably the latter is the wrong choice, because it is already evident it limits what kind of features can be added
59.
▲
by
ericvsmith
6y ago
My bad: it's exec(), not eval(). And I wrote dataclasses, so you'd think I'd know better! The issue is that it's dynamically generating methods. There has to be a way to get dynamically created code into python for this
60.
▲
by
ericvsmith
6y ago
namedtuple and dataclasses both use eval(), so if you want to give up eval(), you'd need to give them up, too.
More ›