TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

What's New in Python 3.11?

322 点作者 sanketsaurav将近 3 年前

21 条评论

salmo将近 3 年前
I’ll just say. Since about 3.6&#x2F;3.8 the language has been growing huge. Like C++ huge.<p>I liked f-strings. Asyncio has its place but is waaay overused. Typing was a cool idea, but so awkward in practice.<p>All of it has really turned me off, personally. It’s getting to where reading libraries is just painful. The simplicity of the language was really beautiful and when I wanted type safety, etc. I’d use something else. I can still write simple Python, but it’s more all the other code I need to grok.<p>I find myself going to Go more and more for stuff I used to use Python for. It’s easier to set up a dev environment for other people, easier to distribute code, and gives me type safety and concurrency as first class citizens while being a very small language.<p>I miss dictionary comprehensions and other shortcuts from time to time. But it actually feels more ergonomic now.<p>All personal opinion. I’m fine shifting languages. I still write C from time to time to bang bits. I play with various LISPs to exercise my brain. I never used Python for performance critical code. I guess ML is changing that need.<p>But I know others that want Java to have functional features and Python to have this stuff.<p>I’m not saying I’m “right”, just uncomfortable in a place I used to love to hang out in.
评论 #31891520 未加载
评论 #31890327 未加载
评论 #31890337 未加载
评论 #31890209 未加载
评论 #31890491 未加载
评论 #31892553 未加载
评论 #31890789 未加载
评论 #31890322 未加载
评论 #31890715 未加载
评论 #31890020 未加载
评论 #31890529 未加载
评论 #31892346 未加载
评论 #31891010 未加载
评论 #31890355 未加载
评论 #31892234 未加载
评论 #31892970 未加载
评论 #31892335 未加载
评论 #31892165 未加载
评论 #31893052 未加载
评论 #31898805 未加载
throw0101a将近 3 年前
Crickey:<p>&gt; <i>Python 3.11 is up to 10-60% faster than Python 3.10. On average, we measured a 1.25x speedup on the standard benchmark suite. See Faster CPython for details.</i><p>* <a href="https:&#x2F;&#x2F;docs.python.org&#x2F;3.11&#x2F;whatsnew&#x2F;3.11.html" rel="nofollow">https:&#x2F;&#x2F;docs.python.org&#x2F;3.11&#x2F;whatsnew&#x2F;3.11.html</a><p>* <a href="https:&#x2F;&#x2F;docs.python.org&#x2F;3.11&#x2F;whatsnew&#x2F;3.11.html#faster-cpython" rel="nofollow">https:&#x2F;&#x2F;docs.python.org&#x2F;3.11&#x2F;whatsnew&#x2F;3.11.html#faster-cpyth...</a>
评论 #31889841 未加载
评论 #31891158 未加载
评论 #31894032 未加载
6gvONxR4sf7o将近 3 年前
Better error messages is something that literally every single language&#x2F;framework&#x2F;library should prioritize. It improves users lives by more than almost everything else besides correctness. It’s been great to see the improvements in python.
评论 #31890178 未加载
评论 #31891317 未加载
评论 #31893762 未加载
评论 #31890125 未加载
davidatbu将近 3 年前
I&#x27;m really excited for where Python&#x27;s static typing is heading!<p>I doubt that typing Python code will <i>ever</i> become as ergonomic as typescript, simply because typescript doesn&#x27;t have the constraint of modifying the syntax of it&#x27;s &quot;target language&quot; (JS) when it wants to add a feature or whatever, whereas typed python must still be Python, and syntactic changes therefore need to be added much more conservatively.<p>But still, the typing story is improving before my very eyes with every release, and given that Python types are actually available at runtime (allowing for things like pydantic and FastAPI), and that Python has massive adoption in the ML space, all this is making Python a very enticing language to get back to using!
评论 #31891429 未加载
评论 #31891402 未加载
评论 #31910593 未加载
di将近 3 年前
Straight from the horse&#x27;s mouth, if you prefer: <a href="https:&#x2F;&#x2F;docs.python.org&#x2F;3.11&#x2F;whatsnew&#x2F;3.11.html" rel="nofollow">https:&#x2F;&#x2F;docs.python.org&#x2F;3.11&#x2F;whatsnew&#x2F;3.11.html</a>
评论 #31892224 未加载
beisner将近 3 年前
Variadic Generics has the potential to enable all the scientific computing libraries to provide really nice type hints. One step closer to eliminating insidious broadcasting bugs… or running training for 10 hrs only to have a validation loop fail because of a shape mismatch.
评论 #31891609 未加载
评论 #31891232 未加载
评论 #31891251 未加载
评论 #31891279 未加载
评论 #31889845 未加载
评论 #31890112 未加载
barosl将近 3 年前
The addition of a TOML parser to the standard library is really welcome. I&#x27;ve always wanted to use TOML in my Python scripts but having to import an external library made me use JSON instead, which was awkward due to the lack of comments.
评论 #31890947 未加载
评论 #31889870 未加载
评论 #31890064 未加载
评论 #31891482 未加载
评论 #31898096 未加载
asicsp将近 3 年前
The `re` module in 3.11 will support &quot;Atomic grouping and possessive quantifiers&quot;. I recently wrote a blog post about these features: <a href="https:&#x2F;&#x2F;learnbyexample.github.io&#x2F;python-regex-possessive-quantifier&#x2F;" rel="nofollow">https:&#x2F;&#x2F;learnbyexample.github.io&#x2F;python-regex-possessive-qua...</a>
gpm将近 3 年前
I love that they&#x27;re improving the error messages, that looks like a huge productivity improvement for beginners and experts alike.
bulatb将近 3 年前
This unblocks or simplifies so many of my projects. Variadic generics, better exceptions, and TOML in the standard library are huge, self-types are great, and extra speed is always appreciated. Thanks to everyone involved.
评论 #31890598 未加载
linsomniac将近 3 年前
For the longest time I was pretty meh about following newer Python releases, instead preferring to stick with a &quot;python--&quot; subset that would work across all the machines in my fleet. But recently I&#x27;ve really been enjoying the new features and have decided to make 3.10 my standard. In particular, the type annotations make my editor (LunarVim) a LOT smarter and let me find many errors before I even run the code.<p>Part of that has been that Ubuntu 22.04 has 3.10 in it. So, while I&#x27;d like to go up to 3.11, I&#x27;m not sure there&#x27;s a good story for adding 3.11 to a 22.04 system.
belval将近 3 年前
Does anyone actually use asyncio for processing stuff? It&#x27;s been around for a while now but I still find it very awkward compared to just creating a pool and calling map or starmap.<p>Am I missing out?
评论 #31889431 未加载
评论 #31899895 未加载
评论 #31891075 未加载
j16sdiz将近 3 年前
The note in exception design is interesting. This allow more contextual information to be embedded.
评论 #31891943 未加载
3np将近 3 年前
Not explicitly mentioned but demonstrated: reveal_type<p><a href="https:&#x2F;&#x2F;docs.python.org&#x2F;3.11&#x2F;library&#x2F;typing.html#typing.reveal_type" rel="nofollow">https:&#x2F;&#x2F;docs.python.org&#x2F;3.11&#x2F;library&#x2F;typing.html#typing.reve...</a>
评论 #31892287 未加载
silent_cal将近 3 年前
<i>Previously, if you had to define a class method that returned an object of the class itself, adding types for it was a bit weird, it would look something like this</i>...<p><i>To be able to say that a method returns the same type as the class itself, you had to define a TypeVar, and say that the method returns the same type T as the current class itself.</i><p>This kind of stuff is so crazy to me. I see how types are useful for defining general categories of data (int, string, float), but isn&#x27;t it better to have as few types as possible? It just makes reading and using code more confusing to keep multiplying &quot;types&quot; like this.
评论 #31899798 未加载
TeeMassive将近 3 年前
Glad to see they ported Anyio&#x27;s TaskGroups (or was it from trio?) to the stdlib. Starting tasks so they run concurrently was a huge pain in vanilla Python.
评论 #31892260 未加载
评论 #31890978 未加载
jenny91将近 3 年前
&gt; &quot;TypeError: unsupported operand type(s) for &#x2F;: &#x27;NoneType&#x27; and &#x27;int&#x27;&quot;<p>&gt; It is crystal clear, that data[&#x27;profits&#x27;][&#x27;yearly&#x27;] was None.<p>I wouldn&#x27;t call that exactly &quot;crystal clear&quot; for someone not somewaht experienced with the language or software in general.
jonnycomputer将近 3 年前
A few of the decisions made over the last few years are questionable, imo, but on the whole, most of the changes have been very very welcome, and I just don&#x27;t use the parts I don&#x27;t like.<p>For example, the changes to TypedDict in 3.11 might actually get me to try them out again.
woodrowbarlow将近 3 年前
regarding task groups: can this be used in places where we want to run several tasks until any one (or more) of the tasks exit? (i.e. instead of asyncio.gather, asyncio.wait with return_when=asyncio.FIRST_COMPLETED)
_0xdd将近 3 年前
…for Workgroups?
NonNefarious将近 3 年前
I would like to learn Python and would like to like it, but the significance of whitespace is a huge turn-off.
评论 #31894140 未加载
评论 #31894170 未加载
评论 #31895309 未加载
评论 #31892561 未加载
评论 #31895298 未加载
评论 #31899925 未加载
评论 #31891982 未加载