Python Conference APAC 2024

Optimizing Python Performance: Strategies for Infrastructure Automation and Beyond
2024-10-26 , CLASS #6
Language: Indonesian

Enhancing the performance of Python scripts is a critical challenge for developers striving to optimize efficiency and reduce execution time. This presentation will delve into various methodologies for improving Python script performance, including threading, multiprocessing, and application refactoring.

Python's Global Interpreter Lock (GIL) presents significant challenges in achieving true parallelism, as it permits only one thread to execute at a time, even in a multi-threaded context. We will discuss the implications of the GIL on threading and highlight scenarios where No GIL implementations or workarounds can be advantageous.

Although threading and multiprocessing enable parallel execution, they do not inherently ensure faster runtimes. Threading can be effective for I/O-bound tasks, whereas multiprocessing is more suitable for CPU-bound operations. However, both approaches introduce complexity and potential overhead that can negate performance gains.

Conversely, refactoring the application can lead to substantial performance improvements. By optimizing algorithms, reducing complexity, and leveraging efficient data structures, developers can achieve significant runtime reductions. This presentation will provide practical examples and case studies illustrating how refactoring can be a more effective strategy for performance enhancement compared to merely adding parallelism.

Additionally, this talk will outline our journey to enhance our infrastructure automation, employing several approaches and comparing each to achieve notable improvements. By implementing these strategies, we accomplished a 90% reduction in running time and met our SLA, thereby enhancing productivity. This presentation will offer practical examples and an in-depth exploration of approaches that may be applicable to other use cases as well.


This talk will include both theory and practical examples based on our previous research and experiments in a controlled infrastructure environment to ensure the validity of our hypotheses and engineering decisions for our automation tools.

As an engineer, I thrive on unraveling complex systems and solving technical challenges. Beyond my professional pursuits, I have a passion for cooking and exploring diverse cuisines.