Skip to content

Commit 35d1c03

Browse files
author
MarcoGorelli
committed
poison __iter__
1 parent c3646e5 commit 35d1c03

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

spec/API_specification/dataframe_api/dataframe_object.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from __future__ import annotations
2-
from typing import Sequence, Union, TYPE_CHECKING
2+
from typing import Sequence, Union, TYPE_CHECKING, NoReturn
33

44
if TYPE_CHECKING:
55
from .column_object import Column
@@ -418,6 +418,18 @@ def __divmod__(self, other: DataFrame | Scalar) -> tuple[DataFrame, DataFrame]:
418418
"""
419419
...
420420

421+
def __iter__(self) -> NoReturn:
422+
"""
423+
Iterate over elements.
424+
425+
This is intentionally "poisoned" to discourage inefficient code patterns.
426+
427+
Raises
428+
------
429+
NotImplementedError
430+
"""
431+
raise NotImplementedError("'__iter__' is intentionally not implemented.")
432+
421433
def any(self, skipna: bool = True) -> DataFrame:
422434
"""
423435
Reduction returns a 1-row DataFrame.

0 commit comments

Comments
 (0)