markdown guide
 

Do you have any specific questions?

The general rule is write the code first, optimize later.

Most suggestions are Python agnostic: buffer content, remember to dispose resources, don't leave files open and so on.

 

Yea I asked for, kind of Key Points to be considered and your answer is pretty close, would like to know such stuff. But specifically on Python, like Lambdas are efficient comparing to Functions/Methods(for one liners I'm saying about).

So if you could share me something like this that would be greatly helpful. Hope you understand :)

 

A possible one is to use lists to join long strings instead of creating many strings objects but it makes a difference only if you have massive objects or massive loops.

Example:

v = ["a", "b", "c"]
s = β€œβ€œ.join(v)

Instead of

v = "a"
v += "b"
v += "c"

But this doesn't really matter if you have a few strings, that's why the strategy is code first, optimizations later.

You can help yourself using tools like flake8 plus github.com/PyCQA/flake8-bugbear/bl... or a code formatter like github.com/ambv/black (clear code makes it easier to find issues).

Regarding functions and lambda there's no difference...

Maybe Google for python performance tips but I think you're better off learning how to write good, readable Python first.

Thanks for your suggestion and I will check them for sure..

 

If you're really concerned about it, the answer is simple: don't write in Python. There are many languages that are better suited to "avoiding execution overhead". It was never a design goal for Python, it was designed with completely different goals in mind.

 

I am willing to know, could you enlighten me with those goals please

 

In a nutshell: Python was designed to be executable pseudocode. That is, a tool for explaining algorithms. You don't "avoid execution overhead" in pseudocode, do you? :-) What you can do, is study the complexity of algorithms, but that's completely orthogonal.

 
Classic DEV Post from Jan 22

Self Care for Developers

Self care is a hot topic these days, and I’m not just talking about face masks. There is a growing movement that underscores the importance of taking time to take care of yourself (in addition to all the other things that you already take time for). You can prevent problems down the road by taking proactive steps to ensure your health and happiness.

Vishwas Mahadev profile image
I'm a Software Professional, passionate on programming