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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Notes on CPython Lists

3 点作者 rusbus超过 7 年前

2 条评论

fernly超过 7 年前
Hmm. You mention having<p>&gt; ...Another reason to preallocate Python lists when possible.<p>But how would one do that? I mean, you could do `list(range(10000))` which would in a sense pre-allocate a 10000-element list. But, does the `list()` operation look ahead and make a list that size at once, or does it just keep appending the next item from the iterable, going through the 12% expansions multiple times?<p>Also, I can&#x27;t think offhand of an iterable that would generate N identical &quot;empty&quot; list items. Like 10000 zeros or 10000 Nones. Anyone?
est超过 7 年前
&gt; Creating List slices ... with some sort of copy-on-write semantics<p><a href="https:&#x2F;&#x2F;docs.python.org&#x2F;3&#x2F;library&#x2F;stdtypes.html#memoryview" rel="nofollow">https:&#x2F;&#x2F;docs.python.org&#x2F;3&#x2F;library&#x2F;stdtypes.html#memoryview</a>