This comment runs on the GPU 💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
If you use the 🤮 88 times instead of the 💩 721 times, it pipes the code through the flux capacitor and gives you your answer the day before you run it!
Just reply back with 721 joy 😂 emojis and a quick snooze (or check your phone, anything that takes a second). It will speed up the conversation. Your welcome
@@padre_putativo_suscriptor "of its kind". What kind? Even Javascript is faster. Python is fast only when you're writing it. It is a library language. It is just used to call functions from other libraries whoch use better languages to do real computing. Throw a for loop at Python and you can see how shamefully slow it is. C++ is my preferred language and that's what I would call a fast language. Don't even get started on Assembly. It is a skill issue if C/C++ can't be almost as fast as Assembly. Programming operations that run fast require language that has the ability to be fast in the first place. Please Note: "Fast" doesn't mean you get the output right away. "Oh i can see how fast it goes. It is like zap", said the dumb guy whose code was to add two numbers. There is an objective way to measure performance and Python isn't even on the list of winners.
I mean, putting a random delay is a legit thing. Customer: build this script! Me: *builds super fast script* Customer: When I input a number, the script produces the result instantly. It feels like it doesn't even think about the result. Are you sure it works correctly? Me: *inserts 1s delay* Customer: Ahhh, much better! Now I know it's calculating because it takes a bit of time
This is a legitimate psychological effect designers have noticed when doing "complex" tasks that computers can finish in seconds, it makes the user think the computer is actually thinking about it and instills trust. Used especially and extensively for hotel bookings, flight searches, money calculation sites etc.
@@heyjakeay I often add animations to things like save buttons that run longer than what the process actually takes to run just so that the user doesn't get confused when it finishes in a fraction of a second and they don't see or notice anything.
@@MartinBarkerTurboTax is one of the more infamous examples of pretending like it's doing something, so they can keep convincing people that filing taxes is hard and definitely something they should take care of instead of the government.
# I'm learning Python, so I took it as a homework assignment def poo_721(func): def wrapper(*args, **kwargs): print("💩" * 721) return func(*args, **kwargs) return wrapper @poo_721 def calculate_grade(score): if score < 60: return "F" if score > 89: return "A" return chr(74 - score // 10) # driver code for n in range(101): print(n, calculate_grade(n)) # EDIT: I implemented a poo decorator. The idea being that the poo decorator can be used to optimize many other functions :)
I would say that this poop is polished but it is in fact decorated. You forgot @wraps(func) before your wrapper function. This decorator adds the inner decorator function automatically and avoids additional nesting. Ensure to from functools import wraps. Other than that decent job.
Now take it a step further by making an ABCMeta class with overridden __call__ / __new__ to wrap every function of all inherited classes with this decorator.
If we aren’t using quantum optimisations, most efficient way is by making a dict that contains the number and grade. You can make separate function for doing distance calculation with NUMPY.
@@RemoteAccessGG from my own experience dicts in Python need much memory (tried soke python scripts on microcontroller, circuit Python), and depending in the direction it can be much better to use tuples (with a[number-lowestnumber]), or if the input is a char, get the number of it, subtract to lowest possible numer, and use a tuple
Refactoring it further to remove below 90% scores and ran the code it on Google tensor and Intel CPU. Core temps reached 110C with 0% battery remaining in an instant
This code kicked in an advanced AI which derived that the student's score was low due to external factors like war and global warming, so it took the discretion to assign them a more appropriate grade.
I add sleeps everywhere in my code, that way, when people ask me to optimize it, I turn a few off and people think I'm brilliant. Nice trick with the emoji's though, adding the memory addressing binary overflow to accelerate the processor. Only works with the exact number of poop emojis.
I know this is a meme video, but the most "efficient" way would probably be to have an array or a string containing the grades and then do some math on the score to get the index matching the grade
It's not going to speed up your 5 lines of Python to put them on a GPU lol, in fact the overhead alone will be killer, but in addition, you're doing multiple conditionally branched instructions on one data point which is the exact opposite of what GPUs are good at. Edit: Lmao I'm an idiot he's being sarcastic. My bad y'all. Don't be like me.
I knew this would be fun to read because it was edited, and I wasn't wrong. It happens to everyone at some point in their lives, and I respect the fact that you left the comment up instead of deleting it.
My Try: def grade(score): score = score//10 match score: case 10: return 'A' case 9: return 'A' case 8: return 'B' case 7: return 'C' case 6: return 'D' case _: return 'F'
Jokes apart, don't do this. Pattern matching in python is different to switch cases in other languages. Since this is not the right use case, it might lead to other issues like performance and maintainability.
I was facing gpu driver issues in out on PREM production server with poppy code now it’s 🚀 , just make sure you maintain the 721 hyper parameter for perfect tuning
Create look up table, switch score by 50 and then divide the changed score by 10, then use the output from the operations as your index. 0 means F, 1 means D, 2 means E, 3 means F... Pretty simple solution.
“Make it more efficient by making it slower” I was so fucking confused for a good 20 seconds trying to understand why you were just adding a time buffer lmao
Yes. This is a problem I'm facing where my for loop runs too quickly when calling a function. Ended up executing the final instance only. Had to add sleep(0.1) just to give Python a breather. I think this is the downside of interpreting with Python, I never had timing issues compiling in C++.
You should have added that time.sleep function as a decorator and ad that decoration to each if statement. *Just to make it easier to read.* Where there is a never nester, there is also a never decorator... Idk If I was right, I'm just your average never decorator
If you add "while True: pass" at the beginning of you function, it will actually charge up your CPU so afterwards the code runs in a fraction of a second
And if you're on python 3.11, you can use case blocks instead. Please note you have to print 420 💩's to compensate, or else it generates error 0x45 (error number 69 for non hex readers)
A good alternative to give a score in an optimized way is to use a binary search. So, when you run a score x, you divide 100 by two parts. If it is lower than 60, you set F, if it is above, you can test if it is below 80 or above 80. If below, you can test whether it is below 70 or above 70. If below, you give D, if above you give C. On the other hand, if above 80, you can test whether it is below 90 or above 90. If below, you give B, id above A. This way, since the scores usually form a normal distribution, you are testing fewer if statements in the mean. P.S.: this is truly optimized. Not a joke. Hahaha
Pop emoji. This guy is a troll 🧌 lol
It only works when it’s exactly 721 though. Otherwise it could make your computer smell.
@@robmulla can we add some baby diapers?
This comment runs on the GPU
💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩💩
@@felipedidio4698my gpu has died. now i bought a new one for my macbook air since there are too much emoji that out of apple’s handle
@@robmulla it's great considering I am reading this when I am on the toilet taking a shit :-D
If you use the 🤮 88 times instead of the 💩 721 times, it pipes the code through the flux capacitor and gives you your answer the day before you run it!
You must love danger.
Hilarious 😂
I tried and you are troll!!
Suddenly adolf hitler appeared behind me and yelled “HAKENKREUZE!!1!1!! KEIN SCHEIASHAUFEN!!11!”
Hahaha hahaha love it!!!
What emoji do I need to use to get it to output a hoverboard? I want my hoverboard already.
They had us in the first half, not gonna lie
The first suggestion was actually legit 😂 the other two… not so much.
@@robmullaBut the first one ends the code if the other if statements aren't possible which is better in my opinion
@@Ir0nically1The second one acts like that too, because it returns at the first 'true'.
@@StarfoxHUNit's also way more readable.
The return part is true, the poop and the sleep parts are fake
Imagine your coworker asking on the team group chat why are there 721 poop emojis in the server logs
😂
Just reply back with 721 joy 😂 emojis and a quick snooze (or check your phone, anything that takes a second). It will speed up the conversation. Your welcome
@@Smac_Ker and speed up your time at the job too 😅
C++ & C: "We are fast!!!!"
Meanwhile Python: "Let's add sleep() to make sure this function doesn't run too fast."
😂😂
while the language is already shamefully slow
@@friedrichmyers In what way is it shamefully slow? Its not shameful if speed isn't the intention.
Add time.sleep to mitigate meltdown spectre
@@padre_putativo_suscriptor "of its kind". What kind? Even Javascript is faster. Python is fast only when you're writing it. It is a library language. It is just used to call functions from other libraries whoch use better languages to do real computing. Throw a for loop at Python and you can see how shamefully slow it is. C++ is my preferred language and that's what I would call a fast language. Don't even get started on Assembly. It is a skill issue if C/C++ can't be almost as fast as Assembly. Programming operations that run fast require language that has the ability to be fast in the first place.
Please Note: "Fast" doesn't mean you get the output right away. "Oh i can see how fast it goes. It is like zap", said the dumb guy whose code was to add two numbers. There is an objective way to measure performance and Python isn't even on the list of winners.
I mean, putting a random delay is a legit thing.
Customer: build this script!
Me: *builds super fast script*
Customer: When I input a number, the script produces the result instantly. It feels like it doesn't even think about the result. Are you sure it works correctly?
Me: *inserts 1s delay*
Customer: Ahhh, much better! Now I know it's calculating because it takes a bit of time
This is a legitimate psychological effect designers have noticed when doing "complex" tasks that computers can finish in seconds, it makes the user think the computer is actually thinking about it and instills trust. Used especially and extensively for hotel bookings, flight searches, money calculation sites etc.
@@heyjakeayi think it is also used that you can be sure, that it isn't booked multiple times, from different places, and so one
@@heyjakeay citation please i really wanna read that paper and find out everything about that.
@@heyjakeay I often add animations to things like save buttons that run longer than what the process actually takes to run just so that the user doesn't get confused when it finishes in a fraction of a second and they don't see or notice anything.
@@MartinBarkerTurboTax is one of the more infamous examples of pretending like it's doing something, so they can keep convincing people that filing taxes is hard and definitely something they should take care of instead of the government.
Just tested in production. Blazingly fast.
It is so fast that it can be difficult to make it to the toilet and plumber will have a lot of work with 721 💩
More like crappily fast!
I'm testing this in prod thanks
That’s the only way to properly test new code. 😂
@@robmulla be sure to accredit the author of this algorithm to make any algo O(1)
@@robmulla Adding "Drop Database ..." Statement to prod makes your app even faster😂😂😂😂
Prod is also the only real prod-like environment you have, so good idea.
# I'm learning Python, so I took it as a homework assignment
def poo_721(func):
def wrapper(*args, **kwargs):
print("💩" * 721)
return func(*args, **kwargs)
return wrapper
@poo_721
def calculate_grade(score):
if score < 60: return "F"
if score > 89: return "A"
return chr(74 - score // 10)
# driver code
for n in range(101):
print(n, calculate_grade(n))
# EDIT: I implemented a poo decorator. The idea being that the poo decorator can be used to optimize many other functions :)
Nice! No poop emojis though :/
I would say that this poop is polished but it is in fact decorated.
You forgot @wraps(func) before your wrapper function. This decorator adds the inner decorator function automatically and avoids additional nesting.
Ensure to from functools import wraps. Other than that decent job.
Now take it a step further by making an ABCMeta class with overridden __call__ / __new__ to wrap every function of all inherited classes with this decorator.
def calculate_grade(score):
return 'FDBCA'[score // 10 - 5]
maybe this faster
@@Be3y4uuK0T forgot time.sleep(1)
If you had just said “optimize this function by making it slower” and added a sleep for 5ms, I’m sure some people would be routinely doing it now.
I guess he wanted it to be obvious 😂... He actually had me at the first half I wouldn't lie😂
@@AdeogoSosanya-hh6uothe first thing is code. probably doesn't change the time per execution much, helps to understand what happens
"the sleep ensures the function isn't run too fast"
Don't worry, by writing your code in python, it will never run too fast.
if you write in JavaScript, it wouldn't run faster either 🤷
@@yanantonio4016you seem to be experienced in js, can you tell me which projects are necessary in js to make us understand it even more ?
you can do it in 1 line of code
def f(score):
return 'F' if score < 60 else chr((100 - score) // 10 + ord('A'))
If we aren’t using quantum optimisations, most efficient way is by making a dict that contains the number and grade. You can make separate function for doing distance calculation with NUMPY.
Looks to me like the most efficient way would be a hash map
are you sure about that in Python? especially thinking about storage as well
@@schwingedeshaehers you also can spend a little of your time making a dict / hashmap with ranges, but I prefer flexibility.
@@RemoteAccessGG from my own experience dicts in Python need much memory (tried soke python scripts on microcontroller, circuit Python), and depending in the direction it can be much better to use tuples (with a[number-lowestnumber]), or if the input is a char, get the number of it, subtract to lowest possible numer, and use a tuple
I am a complete noob but this guy explained so well I understood everything
Please refrain from described practice!!
@@Hizashisamwhat is described practice?
@@alfredogunbayoif you’re here you already know, heed the warning 🤲🏾
Never thought I'd see a Python comedian.
☠️☠️☠️
I used this trick. My cto told me I get a raise!! Thanks man!!
for real??
@@originalbinaryhustler3876 no lol
A raise as in "raise an error", perhaps
Thanks I’ll definitely use these tricks on the code that my boss told me to improve. Can’t wait to see his satisfaction tomorrow ! :)
You might as well buy something expensive on amazon tonight because when your boss sees these implemented he will immedately give you a raise.
@@robmulla He should buy an expensive house using a loan
me when I print 721 shit emojis to a client
The second the video popped up, I went “ehhh, needs some guard clauses” 🤣
Refactoring it further to remove below 90% scores and ran the code it on Google tensor and Intel CPU. Core temps reached 110C with 0% battery remaining in an instant
Every cell in my body feels pain watching this 😂
Now I’m questioning everything you ever told me in the data science videos!
sums up every python programmer out there
I paused the video midway for about a minute trying to guess what the optimization would be
This guy taught me the basics of data science in Python. This should be true.
You can also use pandas to train a ML model then use the continuem transfunctioner to egg out 10% more speed.
Me: *checks today's date halfway through the video*
Haha. You picked up on it quick.
im curious on how he says it with a straight face 😂
You put 50 and it returned C instead of F
bad edit
This is because of speed optimization!
This code kicked in an advanced AI which derived that the student's score was low due to external factors like war and global warming, so it took the discretion to assign them a more appropriate grade.
Branches aren’t thread safe so we need to import antigravity to load the proper GPU libraries that convert every branch to thread safe code
This is a whole new genre of content.
Hopefully you enjoyed.
Yeah this is super
Important. one time I only used 720 in production and all of TH-cam crashed
Rob Mulla has been and is still such a help throughout my Data Science journey that for a sec or two I considered even this advice legit.
Holy crap I’m a lil baby who uses scratch and this is mighty similar, just in letters, I might to migrate to Python
I did put it straight into production code. Thx for the advice, bro.
this feels just as useful as the average python tips video lol
Most pythonic way. 😎
calculate_grades = lambda x: ['D', 'C', 'B', 'A', 'A', 'F'] [v if ((v:=int(x/10)-6)>=0) else 5]
I add sleeps everywhere in my code, that way, when people ask me to optimize it, I turn a few off and people think I'm brilliant.
Nice trick with the emoji's though, adding the memory addressing binary overflow to accelerate the processor. Only works with the exact number of poop emojis.
I know this is a meme video, but the most "efficient" way would probably be to have an array or a string containing the grades and then do some math on the score to get the index matching the grade
Excellent software learnings going on here.
It seems very accurate according to some coders of legacy codes I have faced.
By testing I found magic happens when you keep squaring icon count for each if statement, GPU goes into superpower mode.
Published on arXiv
me making a list and indexing into it
It's not going to speed up your 5 lines of Python to put them on a GPU lol, in fact the overhead alone will be killer, but in addition, you're doing multiple conditionally branched instructions on one data point which is the exact opposite of what GPUs are good at.
Edit: Lmao I'm an idiot he's being sarcastic. My bad y'all. Don't be like me.
I knew this would be fun to read because it was edited, and I wasn't wrong. It happens to everyone at some point in their lives, and I respect the fact that you left the comment up instead of deleting it.
Coincidentally, I am popping and watching this simultaneously. What a life!
How could you not mention the hidden +0.01% optimization by adding semicolons
This is one of the most helpful python shorts I've seen. Thank you sir.
If you use the 👺 emoji this memory location gets passed to the quantum processor and finishes with every grade possible almost instantly
Crazy what languages that don't have an effects system can do in the middle of a seemingly harmless function
My Try:
def grade(score):
score = score//10
match score:
case 10:
return 'A'
case 9:
return 'A'
case 8:
return 'B'
case 7:
return 'C'
case 6:
return 'D'
case _:
return 'F'
For simple cases like this, if-elsif statements are faster
Jokes apart, don't do this. Pattern matching in python is different to switch cases in other languages. Since this is not the right use case, it might lead to other issues like performance and maintainability.
for a second I had to check if it was still april
hi, i added this to my github last week. do you think this project is enough for senior python developer? thank you
That is why the boss thinks we are popping in the code.
Thanks! Uing this to optimize the performance of this web server I'm running on a headless VM!
What program are you using to code and i'm very curious thank you ❤
I laughed when you added poopomozi even when i wanted to praise :)
I was facing gpu driver issues in out on PREM production server with poppy code now it’s 🚀 , just make sure you maintain the 721 hyper parameter for perfect tuning
Good game my dude
You had me ngl 😂😂
score_map = { range(9, 11): ‘A’, 8: ‘B’, 7: ‘C’, 6: ‘D’, range(0, 6): ‘F’ }
return score_map[score // 10]
Create look up table, switch score by 50 and then divide the changed score by 10, then use the output from the operations as your index. 0 means F, 1 means D, 2 means E, 3 means F... Pretty simple solution.
“Make it more efficient by making it slower” I was so fucking confused for a good 20 seconds trying to understand why you were just adding a time buffer lmao
I want my performance to increase by 10k % pop emojis rule
This guy a true Python programmer 🙂
JAVASCRIPT SWITCH STATEMENT
i was very confused until i read the title 😂
One of the first things my CST professors taught with functions was to not early return. And I’m like “why”
U got me but I don’t like you mess up with my brain 😂
real python code written by real developers to give python any sense of runtime efficiency:
Yes. This is a problem I'm facing where my for loop runs too quickly when calling a function. Ended up executing the final instance only. Had to add sleep(0.1) just to give Python a breather. I think this is the downside of interpreting with Python, I never had timing issues compiling in C++.
Mooom'! The computer has dihareea! 😂
You should have added that time.sleep function as a decorator and ad that decoration to each if statement.
*Just to make it easier to read.*
Where there is a never nester, there is also a never decorator...
Idk If I was right, I'm just your average never decorator
what ide is that, cuz it looks sick (is it vscode jupyter?)
If you add
"while True:
pass"
at the beginning of you function, it will actually charge up your CPU so afterwards the code runs in a fraction of a second
What editor are you using?
You are trolli... wait 10 thousand percent? I'm sold!
I NEVER EVER EVER WANT TO SEE THAT FIRST EXAMPLE EVER AGAIN WTF
I am following you only because this was so plausible and made me laugh.
IDK poop emoji; but I too learned that sleep timers show speed or time stepping of your code.
says to optimise code*
purposefully slows it down*
Would a switch case be even faster?
Lol I should've read the title before watching, well done
I mean ... April Fool's day is just around the corner
Now Python has got "match" block. It's like switch case in others languages... Use it.
That’s perfect for cold nights!
And if you're on python 3.11, you can use case blocks instead. Please note you have to print 420 💩's to compensate, or else it generates error 0x45 (error number 69 for non hex readers)
Turtle activated lol
If it wasnt for the poop emoji this shit mightve even go past and around most junior IT/devs ive met ngl
how about
def calculate_grade(score):
return 'F' if score < 60 else chr(max(74 - score // 10, 65))
I'm more concerned about the returns on the same line with the if staments.
You can also use threads
dude you are funny af!!!
I like the refactoring though!
I appreciate it! What's so funny though :D
@@robmulla 😇😇
@@robmulla you actually had me going for a while! i love it 👊🏻👊🏻
why are we making is slower? i didn't get the idea of adding 721 poop emoji.
I tho he gonna use a hashmap but he rickrolled me instead 💀
Talk about (ir)regular expression(s)
169 🍑's works as well. Apparently it raises CPU temperature which in turn makes GPU do the work.
A good alternative to give a score in an optimized way is to use a binary search. So, when you run a score x, you divide 100 by two parts. If it is lower than 60, you set F, if it is above, you can test if it is below 80 or above 80. If below, you can test whether it is below 70 or above 70. If below, you give D, if above you give C. On the other hand, if above 80, you can test whether it is below 90 or above 90. If below, you give B, id above A. This way, since the scores usually form a normal distribution, you are testing fewer if statements in the mean.
P.S.: this is truly optimized. Not a joke. Hahaha
Can we use any emoji other than the poop emoji?
I went through the video faster by watching only first 15 sec.😂
What IDE are you using?
This is a nuanced hack that also works in C++