Use THIS To Check If Your Code Is Optimized In Python

preview_player
Показать описание
Use this to check if your code is optimised in Python. #code #programming #python
Рекомендации по теме
Комментарии
Автор

Worth mentioning that timeit returns the total run time, not the average run time.

Just in case someone complains about how Python is slow even for such a simple task :))

bycare
Автор

To get optimized functions or results in your program.

Reduce function calls as much as you can
Reduce if statements as much as you can

How:
1. If you can manually create the solution do it that way. If you're initializing a value to a variable multiple times, just place it outside of the scope and call on it one time.
2. Find alternatives to reduce if statements as much as possible.

LittlesProductReviews
Автор

You should use the format specifier for rounding instead of doing the round as a function :)

spaghettiking
Автор

Hi indently, I’m wondering, if you noticed. Did you compare list comprehension and just list returns? Can you explain why. Thanks 🙏

AmehaAddis
Автор

Indently: So today guys i'll feed this snail well so that can run fast.
Gigachad Rust Dev:

tmahad
Автор

If you're always trying to optimize your code you can quickly fall into the trap of overengineering.

buadam
Автор

Can someone tell me what theme he is using. The brackets look cool you know ❤

zishanakhtar
Автор

Microbenchmarks lie -> "This Lesson Taught Me How To Do Better Benchmarks
"

climatechangedoesntbargain
Автор

What color theme are you using? Thanks

EntryRoot
Автор

Compiled languages: whats the difference?

hiperion_
Автор

You would need a loop though for a big list

alkebabish
Автор

You can also do: return [i for i in range(5)]

lapispheonix
Автор

If you write types everywhere, why not use much faster languages? Like wayway faster languages. And it is me talking, a guy who loves python and these said faster languages as well.

ennead
Автор

what is the variable name: float mean?

caspgin
Автор

I guess I just feel that if I choose Python, I'm aware enough of optimizations that are substantial, and if I needed better optimization, I wouldn't have chosen Python.

vorpal
Автор

Why do you use type hints for literally everything, like, when defining a variable it really isn’t necessary

peanutatomic
Автор

This comment section is a heaven of premature optimization.
I'm getting tired.

SkyyySi
Автор

i think cpu usage is more important that time usage😊

gamingland
Автор

python import module "timeit" to check which code block/line is optimized

jonsantos
Автор

Also remember you can use the globals keyword with a dict of variables to put some in

AkivaB