Welcome!

Scrivere codice Python efficiente

Logan Thomas

Scientific Software Technical Trainer, Enthought

Course overview

  • Your code should be a tool used to gain insights
    • Not something that leaves you waiting for results
  • In this course, you will learn:
    • How to write clean, fast, and efficient Python code
    • How to profile your code for bottlenecks
    • How to eliminate bottlenecks and bad design patterns
Scrivere codice Python efficiente

Defining efficient

  • Writing efficient Python code
    • Minimal completion time (fast runtime)
    • Minimal resource consumption (small memory footprint)

alt="Equation with a stopwatch next to an arrow pointing down plus a memory stick next to an arrow pointing down equalling the word efficient"

Scrivere codice Python efficiente

Defining Pythonic

  • Writing efficient Python code
    • Focus on readability
    • Using Python's constructs as intended (i.e., Pythonic)

# Non-Pythonic
doubled_numbers = []

for i in range(len(numbers)):
    doubled_numbers.append(numbers[i] * 2)

# Pythonic doubled_numbers = [x * 2 for x in numbers]
Scrivere codice Python efficiente

The Zen of Python by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
...
Scrivere codice Python efficiente

Things you should know

Scrivere codice Python efficiente

Let's get started!

Scrivere codice Python efficiente

Preparing Video For Download...