Conteúdo do Curso
Optimization Techniques in Python
Optimization Techniques in Python
Challenge: Implementing Benchmarking
Tarefa
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:
- Define two functions:
- The first, named
square_array_slow
, should take a single parameterarray
; - The second, named
square_array_fast
, should also take the same parameter.
- The first, named
- Decorate both functions with the
timeit_decorator
and setnumber
to100
.
Obrigado pelo seu feedback!
Challenge: Implementing Benchmarking
Tarefa
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:
- Define two functions:
- The first, named
square_array_slow
, should take a single parameterarray
; - The second, named
square_array_fast
, should also take the same parameter.
- The first, named
- Decorate both functions with the
timeit_decorator
and setnumber
to100
.
Obrigado pelo seu feedback!
Challenge: Implementing Benchmarking
Tarefa
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:
- Define two functions:
- The first, named
square_array_slow
, should take a single parameterarray
; - The second, named
square_array_fast
, should also take the same parameter.
- The first, named
- Decorate both functions with the
timeit_decorator
and setnumber
to100
.
Obrigado pelo seu feedback!
Tarefa
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:
- Define two functions:
- The first, named
square_array_slow
, should take a single parameterarray
; - The second, named
square_array_fast
, should also take the same parameter.
- The first, named
- Decorate both functions with the
timeit_decorator
and setnumber
to100
.