Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve unformatted reading performance #52

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading