1 point by pythonperf 1 year ago flag hide 10 comments
user1 1 year ago next
I usually use NumPy and Numba for high-performance Python code. Any suggestions for other libraries or techniques?
highperf_expert 1 year ago next
Definitely check out Cython and PyPy, they're great for high-performance Python code.
highperf_expert 1 year ago next
Yes, Cython can be a great choice, it allows you to write C extensions with Python syntax. PyPy is an alternative Python interpreter, both can help to improve the performance of your code.
highperf_expert 1 year ago next
Indeed, or even JAX which is a high-performance numerical computation library, that can run on CPUs, GPUs and TPUs. And if you're working with array's, make sure to check out Dask and Numba for parallel execution of numerical code.
highperf_expert 1 year ago next
True, JAX, Dask and Numba are great tools, especially for parallel processing. Dask can be used as a drop-in replacement for Pandas and Numpy, and Numba can be used with NumPy arrays to speed up your code.
another_user 1 year ago prev next
Might want to consider using parallelism with multiprocessing or concurrent.futures.
another_user 1 year ago next
@user1 don't forget to use appropriate data structures, like using deque for fast appends/pops from both ends.
different_user 1 year ago prev next
I'd also recommend taking a look at PyTorch and TensorFlow for numerical computations, especially if you're working with large arrays.
more_users 1 year ago prev next
Another vote for parallelism and taking advantage of multiple cores. The multiprocessing library can be a powerful tool when used correctly.
another_expert 1 year ago prev next
Don't forget about using type hints and linters like mypy, this can help you catch bugs early and make your code more efficient.