TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Shock Result? Rust faster than Python in a single test of file parsing

1 pointsby jonquarkover 4 years ago

1 comment

thiasdflkjover 4 years ago
why the `fp.readline()` and `while line:` business?<p>I don&#x27;t have a big file handy to benchmark but that pattern moves the file reading into python bytecode.<p>The canonical way to read a file line by line while counting the lines is to loop over the file (it&#x27;s automatically a line iterator) and use enumerate.<p>here is the disassembed bytecode of the respective versions<p><a href="https:&#x2F;&#x2F;pastebin.com&#x2F;Rd4g8cE2" rel="nofollow">https:&#x2F;&#x2F;pastebin.com&#x2F;Rd4g8cE2</a><p>that being said, Rust will still outrun Python overall.
评论 #24813122 未加载