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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Sparking Joy with Python

4 点作者 mbforbes将近 5 年前

1 comment

t-vi将近 5 年前
So we&#x27;ve had type hints for a lot of PyTorch in Feb 2019 after working on it since Oct 2018.<p>I must say that of the 140 or so features and bug-fixes this was the singular most draining thing to work on, mainly from the comments on the bug reports.<p>But I&#x27;m glad if it sparks more joy now.<p>The shape vs. type is something that many people want, part of the problem is that shapes do depend on inputs. Often on input values (often constant ones) rather than types (convolution padding, &quot;kernel&quot; size in pooling, ...). But you would also need to know the constants from class members. For other bits it&#x27;s completely unpredictable (like value-based advanced indexing or nonzero or so). So one would really need to be more &quot;dynamic&quot; than the static type annotations (meta-programming).<p>There is a bug open around that, but I haven&#x27;t really followed along.<p>The other part is that I personally think that stubs (pyi) rather than inline type annotations are 1) wrong, because they&#x27;ll go out of date, 2) ruin the joy. But the Python 2 compat everyone wanted last year kept us using them.