# Что из себя представляют range объекты и в чем их отличие от списков?

В Python `range` — это **ленивый** (невычисляемый сразу) последовательный генератор чисел, а не список.

#### Основные свойства `range`:

1. **Не хранит все значения** — содержит только начальное число, шаг и конечную границу.

   ```python
   r = range(0, 10, 2)  # хранит start=0, stop=10, step=2
   ```
2. **Выделяет мало памяти** — независимо от количества чисел.

   ```python
   import sys
   sys.getsizeof(range(0, 1_000_000))  # ~48 байт
   ```
3. **Поддерживает индексирование и срезы** — как список, но элементы вычисляются "на лету".
4. **Иммутабелен** — нельзя изменить элементы.

***

#### Отличия от списка (`list`):

| Критерий            | `range`                        | `list`                    |
| ------------------- | ------------------------------ | ------------------------- |
| Память              | O(1)                           | O(n)                      |
| Вычисление значений | При обращении к элементу       | Хранит все значения сразу |
| Изменяемость        | Нет                            | Да                        |
| Скорость итерации   | Быстрее при больших диапазонах | Может быть медленнее      |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kaze.gitbook.io/qa-theory/osnovy-programmirovaniya-na-python/chto-iz-sebya-predstavlyayut-range-obekty-i-v-chem-ikh-otlichie-ot-spiskov.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
