Python Benchmark: Сравнение поиска в списке и в range

Looking for a fast way to "Сравнение поиска в списке и в range" in python? Check below to see see which method is the fastest and uses less memory.

Packages

Setup

Runs before the benchmark, and it is not measured. Good place to import libraries and prepare data. Learn more

Code 1

Code 2

Teardown

Results

Fastest

Поиск в range-объекте

43.9 us

22.8K op/s

Speed

BenchmarkRuntime
Operations
VS
Visual
Поиск в range-объекте43.9 us22.8K op/s0.00004390907214166453
Поиск в списке (тип list)475 ms2.11 op/s10813×0.4747958070365712

Memory

BenchmarkPeak Memory
Score
VS
Visual
Поиск в списке (тип list)< 1 KB8.320
Поиск в range-объекте< 1 KB12.40

Output

Поиск в range-объекте
No output
Поиск в списке (тип list)
No output