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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Create objects 2x faster in Python

4 点作者 ertug将近 15 年前

1 comment

j_baker将近 15 年前
This is a pretty bad benchmark. Of course the harbor with pooling is faster. It's creating all 100000 objects outside the timer, while the harbor without pooling is creating them within the timer. If I change the code so that it creates the objects inside the timer, I get the following results which are nowhere near as good:<p><pre><code> Total With Object Pooling: 633.393 ms Total Without Object Pooling: 714.89 ms </code></pre> This is hardly 2x faster and the speed increase that is there probably comes more from allocating the objects in a list comprehension in the pooled harbor.
评论 #1431152 未加载