Skip to content

Conversation

@pierotofy
Copy link
Contributor

@pierotofy pierotofy commented Feb 24, 2025

Closes #253

I've tested this by running:

import rawpy

with rawpy.imread("iss030e122639.NEF") as f:
	print(f.sizes)
	print(f.num_colors)
	print(f.color_desc)
	print(f.raw_colors_visible)

And verifying that outputs match between this branch and main.

Now, raw_colors_visible accesses raw_colors, which still calls ensure_unpack. To get a better benchmark, one can do:

import rawpy

with rawpy.imread("iss030e122639.NEF") as f:
	print(f.sizes)
	print(f.num_colors)
	print(f.color_desc)
[pt:~/Documents/rawpy/test] [venv] unpackopt+* ± hyperfine 'python test.py'
Benchmark 1: python test.py
  Time (mean ± σ):     106.9 ms ±  19.7 ms    [User: 521.1 ms, System: 144.5 ms]
  Range (min … max):    92.2 ms … 175.6 ms    16 runs

vs. main branch:

[pt:~/Documents/rawpy/test] [venv] main+* 4s ± hyperfine 'python test.py'
Benchmark 1: python test.py
  Time (mean ± σ):     345.6 ms ±  12.3 ms    [User: 1732.8 ms, System: 491.4 ms]
  Range (min … max):   319.7 ms … 359.2 ms    10 runs

@letmaik letmaik merged commit afa8170 into letmaik:main Mar 1, 2025
58 checks passed
@letmaik
Copy link
Owner

letmaik commented Mar 1, 2025

Thanks for the PR!

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.

Optimization: speeding up certain attribute access by not calling ensure_unpack()

2 participants