Skip to content

Commit c68984b

Browse files
committed
Add comments to record findings of attempts to use enums
Update shapefile.py
1 parent b0563c5 commit c68984b

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/shapefile.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,11 @@ def read(self, size: int = -1) -> bytes: ...
205205

206206
# https://en.wikipedia.org/wiki/.dbf#Database_records
207207
class FieldType:
208-
"""A bare bones 'enum', as the enum library noticeably slows performance."""
208+
"""A bare bones 'enum', as the enum library used to noticeably slow performance.
209+
A StrENum could be used instead, once the minimum supported Python
210+
version >= 3.11. But the Public API supports passing strings into
211+
Field (a NamedTuple which used to just be a plain tuple[str,str,int,int]).
212+
"""
209213

210214
C: Final = "C" # "Character" # (str)
211215
D: Final = "D" # "Date"
@@ -1106,6 +1110,7 @@ class GeoJSON_Error(Exception):
11061110
pass
11071111

11081112

1113+
# Could be an Enum, but an isinstance check is still needed.
11091114
class _NoShapeTypeSentinel:
11101115
"""An instance is the default value for Shape.__init__,
11111116
to preserve old behaviour for anyone who explictly
@@ -3572,6 +3577,7 @@ def iterShapes(
35723577
assert n == len(self.headers_cache), f"{n=}, {len(self.headers_cache)=}"
35733578

35743579

3580+
# Could be an enum, but an isinstance check is still needed.
35753581
class _NoShpSentinel:
35763582
"""An instance is the default value for shp to preserve the
35773583
old behaviour (from when all keyword args were gathered

0 commit comments

Comments
 (0)