Live data from Hacker News

Ask HN: C/C++ developer wanting to learn efficient Python

news.ycombinator.com

11–20 of 50 posts

Re: Ask HN: C/C++ developer wanting to learn efficient Python

#11
I would say, there is no such thing as fast Python code. It's not the purpose of the language.

You make want to take a look at Mojo: https://www.modular.com/max/mojo

It's not really there yet, but the promise is to "combine the usability of Python with the performance of C"

Re: Ask HN: C/C++ developer wanting to learn efficient Python

#13
Take my reaction with a grain of salt. I'm very much from a "right tool for the right job" type of school, and normally I'm not this emotional but somehow this hit a nerve. I find it funny it hit a nerve. I'm happy you posted! I've learned something about myself.

> I want to gain a similar understanding of what is "fast" in C++ (std::move, copy elison, etc.), but with python.

But why why why why?!

The reason C++ is fast is because it gives you control! The reason Python is usable because it is very opinionated on how it gives you control.

People say "do not fight the framework." This also applies to programming languages.

Next thing you know and people want best practices for modular OOP-design in brainfuck. Now I wonder if brainfuck has something like JSDoc.

Re: Ask HN: C/C++ developer wanting to learn efficient Python

#14
post #6

> How can I improve my ability to write data structure/algo code in python? You don't need a book on Python, you need to practice solving data structures and algorithms problems. Completely disagree with the recommendation to read Fluent Python, that book has nothing to do with your goals. > understanding of what is "fast" Do you mean in terms of performance? Depending on the problem fastest is usually to use librari…

Hmm doing data structures and algorithms in pure python as fast as possible will teach you about the environment's gotchas and limitations.

The answer if it's performance critical is probably "write it in C" but you want to be aware enough to not end up accidentally quadratic in trivial code.

Re: Ask HN: C/C++ developer wanting to learn efficient Python

#17

Take my reaction with a grain of salt. I'm very much from a "right tool for the right job" type of school, and normally I'm not this emotional but somehow this hit a nerve. I find it funny it hit a nerve. I'm happy you posted! I've learned something about myself. > I want to gain a similar understanding of what is "fast" in C++ (std::move, copy elison, etc.), but with python. But why why why why?! The reason C++ is f…

I'm guessing OP would prefer to get the job. Knowing what's fast and what's slow definitely conveys confidence in understanding.

Re: Ask HN: C/C++ developer wanting to learn efficient Python

#19
This depends a lot on the usecase. For example, data scientists prefer using libraries like dask and polars for faster analyses. What you are asking is, in a way, looking under the hood of such libraries. Oftentimes, you will find that under the hood there's C or Rust code.. anyway, check these articles: https://pythonspeed.com/

Re: Ask HN: C/C++ developer wanting to learn efficient Python

#20

I would say, there is no such thing as fast Python code. It's not the purpose of the language. You make want to take a look at Mojo: https://www.modular.com/max/mojo It's not really there yet, but the promise is to "combine the usability of Python with the performance of C"

> I would say, there is no such thing as fast Python code. It's not the purpose of the language.

It's not the purpose of the language but (business) needs don't generally care about such things. Sometimes you can't rewrite in rust for a variety of reasons and then it can pay off to know what's faster rather than slower in CPython.

Post reply on HN