Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Impara Challenge: Implementing Benchmarking | Understanding and Measuring Performance
Optimization Techniques in Python
course content

Contenuti del Corso

Optimization Techniques in Python

Optimization Techniques in Python

1. Understanding and Measuring Performance
2. Efficient Use of Data Structures
3. Enhancing Performance with Built-in Tools

book
Challenge: Implementing Benchmarking

Compito

Swipe to start coding

Let's practice benchmarking by comparing two approaches to squaring the elements of a NumPy array. The first approach, the slower one, uses a for loop to square each element individually, while the second approach leverages vectorization. Don't worry if this concept sounds unfamiliar—we'll discuss it later in the course.

Your task for now is the following:

  1. Define two functions:
    • The first, named square_array_slow, should take a single parameter array;
    • The second, named square_array_fast, should also take the same parameter.
  2. Decorate both functions with the timeit_decorator and set number to 100.

Soluzione

Switch to desktopCambia al desktop per esercitarti nel mondo realeContinua da dove ti trovi utilizzando una delle opzioni seguenti
Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 1. Capitolo 4
toggle bottom row

book
Challenge: Implementing Benchmarking

Compito

Swipe to start coding

Let's practice benchmarking by comparing two approaches to squaring the elements of a NumPy array. The first approach, the slower one, uses a for loop to square each element individually, while the second approach leverages vectorization. Don't worry if this concept sounds unfamiliar—we'll discuss it later in the course.

Your task for now is the following:

  1. Define two functions:
    • The first, named square_array_slow, should take a single parameter array;
    • The second, named square_array_fast, should also take the same parameter.
  2. Decorate both functions with the timeit_decorator and set number to 100.

Soluzione

Switch to desktopCambia al desktop per esercitarti nel mondo realeContinua da dove ti trovi utilizzando una delle opzioni seguenti
Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 1. Capitolo 4
Switch to desktopCambia al desktop per esercitarti nel mondo realeContinua da dove ti trovi utilizzando una delle opzioni seguenti
Siamo spiacenti che qualcosa sia andato storto. Cosa è successo?
some-alt