News for hackers. Stuff that matters.
Re:Proposing a Struct Syntax for Python by olejorgenb on Wednesday June 14, 2023 @02:49PM (#36330722)
This is the reasoning from the article for why its suggestion is better then dataclasses:

> - Typing is optional (there are still folks who don't want to lean into that and it simply isn't always necessary)

> - Class construction should be faster (which intuitively you would think shouldn't matter, but I have talked to folks where this is an actual concern, especially when startup time is critical)

> - Syntax typically leads to better tooling support since there's no ambiguity

> - Easier to teach than (data)classes, so can act as a stepping stone towards classes

> - Better semantics than dataclasses have by default (at least in my opinion )

Re:Proposing a Struct Syntax for Python by pwdisswordfishc on Wednesday June 14, 2023 @03:42PM (#36331475)
> - Typing is optional (there are still folks who don't want to lean into that and it simply isn't always necessary)

Someone who really wants to avoid type annotations at all costs can just use ": object" everywhere

Re:Proposing a Struct Syntax for Python by nomel on Wednesday June 14, 2023 @04:31PM (#36332167)
I believe it should be ": Any".
Re:Proposing a Struct Syntax for Python by agons on Wednesday June 14, 2023 @07:16PM (#36334203)
Hey, you're leaning into it too much!

Who are people who are against typing in this day and age?

Re:Proposing a Struct Syntax for Python by glaucon on Wednesday June 14, 2023 @09:21PM (#36335231)
> Who are people who are against typing in this day and age?

People who don't find the benefits of typing are worth the overhead?

Python is, after all, a dynamically-typed language, so it is, surely, not too surprising that those who use it might include those who want a ... dynamic language ?

If it's too much to take the joys of Java are freely available.

Re:Proposing a Struct Syntax for Python by nomel on Thursday June 15, 2023 @12:16AM (#36336322)
> are worth the overhead?

What overhead, specifically?

I've found it reduces overhead. Rather than using English to describe the types, in the comments/docstrings, I can just type the terse type hint in the function definition, and leave the rest to the documentation renderer. If you don't document anyways, sure.

Re:Proposing a Struct Syntax for Python by yuppiepuppie on Thursday June 15, 2023 @03:14AM (#36337374)
I use python daily and dont use typing. The reason being that I choose python for it readability. And I find typed python to be less readable than non-typed python. If I wanted a typed language, I wouldnt want python.
Re:Proposing a Struct Syntax for Python by IshKebab on Wednesday June 14, 2023 @03:10PM (#36331006)
> there are still folks who don't want to lean into that

Honestly why would you cater to people who want to write worse code? Should Python have a mode with implicit type coercion too because some people can't be bothered to type `int()`?

> Class construction should be faster.

It's Python. You accepted your code would be extremely slow going in. Fiddling with the syntax isn't going to make it fast.

Re:Proposing a Struct Syntax for Python by Groxx on Wednesday June 14, 2023 @03:44PM (#36331505)
Yeah, honestly I think if startup time is a real concern, python is simply the wrong choice. Slow startup is largely inherent in its design.

Not that it's not worth spending some effort to optimize, of course. But the lower bound is quite high even if you're very careful.