Skip to content

Commit 99353e9

Browse files
committed
feat: grand finale, map fast as fuck
1 parent 8a7bef1 commit 99353e9

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

web3/_utils/abi.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@
1414
Coroutine,
1515
Dict,
1616
Iterable,
17+
Iterator,
1718
List,
1819
Mapping,
1920
Optional,
2021
Sequence,
2122
Tuple,
2223
Type,
24+
TypeVar,
2325
Union,
2426
cast,
2527
)
@@ -106,6 +108,9 @@
106108
)
107109

108110

111+
_TValue = TypeVar("_TValue")
112+
113+
109114
def fallback_func_abi_exists(contract_abi: ABI) -> Sequence[ABIFallback]:
110115
return filter_abi_by_type("fallback", contract_abi)
111116

@@ -634,7 +639,7 @@ def abi_data_tree(
634639
>>> abi_data_tree(types=["bool[2]", "uint"], data=[[True, False], 0])
635640
[("bool[2]", [("bool", True), ("bool", False)]), ("uint256", 0)]
636641
"""
637-
return list(map(abi_sub_tree, types, data))
642+
return map(abi_sub_tree, types, data)
638643

639644

640645
@curry

web3/_utils/formatters.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ def map_collection(func: Callable[..., TReturn], collection: Any) -> Any:
6565
If the value is not a collection, return it unmodified
6666
"""
6767
datatype = type(collection)
68+
if datatype is map:
69+
return map(func, collection)
6870
if isinstance(collection, Mapping):
6971
return datatype((key, func(val)) for key, val in collection.items())
7072
if is_string(collection):

0 commit comments

Comments
 (0)