Skip to content

Commit

Permalink
Improve unformatted reading performance
Browse files Browse the repository at this point in the history
  • Loading branch information
eivindjahren committed Jan 9, 2024
1 parent a7568b6 commit ae799eb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/resfo/_unformatted/common.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from functools import lru_cache


def group_len(type_keyword):
"""
The length of element groups in unformatted arrays.
Expand All @@ -21,16 +24,18 @@ def group_len(type_keyword):
}


@lru_cache
def item_size(type_keyword):
"""
:returns: The number of bytes for each element in an
res array of the given res type.
"""
if type_keyword[0:2] == b"C0":
return int(type_keyword[2:4].decode("ascii"))
return static_item_sizes.get(type_keyword, None)
return static_item_sizes.get(type_keyword)


@lru_cache
def bytes_in_array(array_length, item_type):
"""
:param array_length: Number of items in the array
Expand Down

0 comments on commit ae799eb

Please sign in to comment.