Arducam 16MP Autofocus - Take several photos at different focus Efficiently

HI guys!!

1. Where did you get the camera module(s)?
I bought the Arducam 16MP Autofocus in Amazon

2. Model number of the product(s)?
B0371C

3. What hardware/platform were you working on?
Raspberry Pi 4

4. Instructions you have followed. (link/manual/etc.)
I have been following this guide: libcamera and libcamera-apps - Arducam Wiki

5. Problems you were having?
I want to take photos at different focus values as fast as possible but i can not do it. is quite a slow process.
For instance i want to perform this simple routine:
go to lens position 4 → take a photo → go to lens position 50 → take a photo → go to lens position 600 -->take photo … etc etc

  1. Troubleshooting attempts you’ve made?
    I made the following working script but its kinda slow and i can visually see that the mechanical lens goes back to baseline in between every change of focus, which i think is not efficient for time.
import subprocess
import time

def capture_image(output_file, lens_position):
    command = ['libcamera-still', '-o', output_file, '-t', '100', '--autofocus-mode', 'manual', '--lens-position', str(lens_position)]
    subprocess.run(command)

# Capture images with different lens positions
lens_positions = [4, 50, 600]
output_files = ['yei4.jpg', 'yei5.jpg', 'yei6.jpg']

for i in range(len(lens_positions)):
    lens_position = lens_positions[i]
    output_file = output_files[i]

    capture_image(output_file, lens_position)
  1. What help do you need?
    Do you have any example, guide, or information that helps me to take faster/optimal pictures while changing the lens distance? is there maybe a function os instruction im not leveraging?

best regards