Skip to content

fix: associators pass compressed frames as numpy arrays instead of lists - #195

Open
Osayi-ANL wants to merge 1 commit into
mainfrom
fix/associator-tolist-removal
Open

Osayi-ANL wants to merge 1 commit into
mainfrom
fix/associator-tolist-removal

Conversation

@Osayi-ANL

Copy link
Copy Markdown
Collaborator

Both associators converted the compressed frame to a Python list before handing it to pvaccess. Passing the numpy array directly does the same thing ~300x faster.

Change (one line in each associator):

- pvObject['value'] = ({'ubyteValue': arr_u8.tolist()},)
+ pvObject['value'] = ({'ubyteValue': arr_u8},)

Why it was slow:

Before:  numpy array ──tolist()──▶ 1,000,000 Python ints ──one by one──▶ frame    ~98 ms
After:   numpy array ─────────────── one block copy ─────────────────▶ frame    ~0.3 ms

Time per frame (offline test, lz4 included):

Frame size Before After
512×512 ~21 ms ~3 ms
1024×1024 ~80–95 ms ~8–9 ms

Bytes written are identical and the image decompresses to the original. The outdated "PvAccess expects a list" comment is removed.

…ss as a numpy array instead of a list — tolist() cost ~98 ms per 1 MP frame
@Osayi-ANL
Osayi-ANL requested review from gonzaldi and pecomyint and removed request for pecomyint October 27, 2026 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant