Challenge: Implementing Benchmarking
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:
- 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
.
Рішення
Дякуємо за ваш відгук!
single
Запитати АІ
Запитати АІ
Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат
Awesome!
Completion rate improved to 7.69
Challenge: Implementing Benchmarking
Свайпніть щоб показати меню
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:
- 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
.
Рішення
Дякуємо за ваш відгук!
Awesome!
Completion rate improved to 7.69single