Algorithm Optimization: Constant Factor Improvement for Built-in min()/max() in Python

preview_player
Показать описание
Uncover the surprising truth about Python's built-in min() and max() functions! This video dives deep into constant factor optimization, comparing built-in functions with direct comparison approaches. Learn how small optimizations can lead to significant performance gains in large-scale applications. Perfect for Python developers looking to level up their optimization skills and algorithm enthusiasts curious about the intricacies of language design.

0:00 Built-in min()/max() Functions vs Direct Comparison Approach
3:33 Algorithm Complexity & Constant Factor Optimization
4:38 Real-world Example: Social Media Feed Generation
5:36 The Minimum Area Rectangle Problem
7:35 Optimized Simultaneous Min/Max Algorithm

Link to the Experiment Code:
Рекомендации по теме
Комментарии
Автор

Great video! The constant factor optimizations shown in this video are exactly the kind of things that separate good Python developers from great ones. Keep up the excellent content!

Planner-William
Автор

This video was awesome! Seriously very good quality presentation man! Keep making content like this and more people will find you in no time!

driesvanheeswijk
Автор

Subscribed you for this. Please keep such videos that discuss fundamental concepts and applications, looking forward to it!

modimihir
Автор

I like that. I just got into leetcode due to BLE interactions I've been implementing in React Native. The few milliseconds of gain are actually impressive! Even on the mobile side, you have a more robust and consistent UI experience. The goal is always to fine-tune your algorithm for the lowest end devices. Thank you for this video. My next question is what recommendation would you give me if my goal is to consistently do these kinds of tests when I'm trying to compare the performance of different algorithms against each other?

nelinotakam
Автор

Some. glitches in your video. Fix those. This is great content

nelinotakam
Автор

Link to the Experiment Code - Simultaneous Min/Max vs Built-in:

RealRyanRad
Автор

You don’t write Python for speed.
Don’t make your Python code not readable for negligible questionable performance benefits

nitsanbh
Автор

I've heard the sm platforms are very bloated but 500ms of processing sounds extreme.

HhddGufif
Автор

It always boggles my mind why people spend time trying to optimize negligible things while having chosen the almost slowest language on the planet to write their code in. Like if optimized code and performance was that critical why would you pick python in the first place...


Aside from that, I can't possibly imagine that the rest of your code base is so optimized that you are now down to trying to whittle nanoseconds off a min function.

It's like buying high performance tires for your Ford Pinto so you can cut your 1/4 mile time from 17.75 seconds to 17.72...

KMegahertz
Автор

It python champ, there is no point optimising your code for performances. Anything of substance happens in the packages you import.

rockenOne
join shbcf.ru