美文网首页
2020-12-22 Is Python too slow?

2020-12-22 Is Python too slow?

作者: 春生阁 | 来源:发表于2020-12-22 18:28 被阅读0次

    From my perspective, such questions should be asked based on a specific context or use case. Is Python slow in crunching numbers compared to compiled languages such as C? Yes, it is. This fact has been known for years, and that’s the reason why Python libraries for which speed plays an important role, such as numpy, leverage C under the hood.

    But is Python that much slower than other (more difficult to learn and use) languages for all use cases? If you look at the performance benchmarks of many Python libraries optimized to solve a specific problem, they do decently well compared to compiled languages. For instance, look at the FastAPI performance benchmark — obviously, Go as a compiled language is much faster than Python. Still, FastAPI beats some of Go’s libraries for building REST APIs:

    Similarly, when comparing Dask (written in Python) against Spark (written in Scala) for data-intensive neuroimaging pipelines [2], the authors concluded:

    Overall, our results show no substantial performance difference between the engines.

    The question we should be asking ourselves is what speed do we really need. If you run an ETL job triggered only once per day, you may not care whether it takes 20 seconds or 200 seconds. You may then prefer to make the code easy to understand, package, and maintain, especially given that the compute resources are becoming increasingly affordable as compared to the costly engineering time.

    相关文章

      网友评论

          本文标题:2020-12-22 Is Python too slow?

          本文链接:https://www.haomeiwen.com/subject/wvnsnktx.html