Skip to content

Commit 6923649

Browse files
committed
cache bucket parsing
1 parent 28ce036 commit 6923649

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

cloudpathlib/s3/s3path.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,13 @@ def bucket(self) -> str:
8383
8484
:type: :class:`str`
8585
"""
86+
if hasattr(self, "_bucket"):
87+
return self._bucket
8688
if match := _MRAP_PATTERN.match(str(self)):
87-
return match.group("arn")
88-
return self._no_prefix.split("/", 1)[0]
89+
self._bucket = match.group("arn")
90+
else:
91+
self._bucket = self._no_prefix.split("/", 1)[0]
92+
return self._bucket
8993

9094
@property
9195
def key(self) -> str:

0 commit comments

Comments
 (0)