paint-brush
3 Easy Ways to Improve The Performance Of Your Python Codeby@bkotis
922 reads
922 reads

3 Easy Ways to Improve The Performance Of Your Python Code

by Bence Kotis4mJuly 11th, 2020
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

You can benchmark your Python code line by line using line_profiler. This benchmarking library has significant overhead, but it's perfect for finding weak points in your code and replacing them with something more efficient. Avoid loops when possible. Compile your Python modules using Cython or Cython. Cython is not a general purpose python to C compiler, Cython lets you compile your python modules into shared object files(so), which can be loaded by your main python script. For example, the map version is over 6X faster than the original.

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - 3 Easy Ways to Improve The Performance Of Your Python Code
Bence Kotis HackerNoon profile picture
Bence Kotis

Bence Kotis

@bkotis

L O A D I N G
. . . comments & more!

About Author

Bence Kotis HackerNoon profile picture
Bence Kotis@bkotis

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite