Does Pattern('file') cache the source file?

Asked by Dmitry on 2018-09-09

I need to search for a sequence of images on the screen every, like, 0.1 seconds. Will something like...
img1 = Pattern('1.png')
img2 = Pattern('2.png')
imgList = [img1, img2]
while True:
    matches = findAnyList(imgList)
    for match in matches:
        DoSomething(match)

...address to the hard drive for reading the source files every loop cycle, or will it cache the patterns in memory?

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
2018-09-09
Last query:
2018-09-09
Last reply:
2018-09-09
Best RaiMan (raimund-hocke) said : #1

--- 1.1.3
the images are cached and hence taken from memory the second time and later

--- 1.1.4
does not have this caching yet (must be implemented differently)

But this would avoid the reading from the file system the second time and later:

pimg = Pattern( Image.create("img.png")) # the image is read from the filesystem at this time

if you later use pimg, the already loaded image will be used from memory until you reassign pimg.

Dmitry (sdv4) said : #2

Thanks RaiMan, that solved my question.