X-1.0: Is it necessary to destroy finder after casting it to list? --- NO!

Asked by anatoly techtonik

http://sikuli.org/docx/finder.html

Doc says Finder has to be destroyed when used with for: or while:
Is it necessary to destroy it when converting to list? E.g.
  matches = list(finder)

Isn't it destroyed automatically after leaving local scope, where a region.getLastMatches() function was called?

With the information above the second example at http://sikuli.org/docx/finder.html (which could have a link for easy referencing by the way) can be simplified from :
  ...
  f.find(img) # find all matches
  mm = [] # an empty list

  while f.hasNext(): # loop as long there is a first and more matches
        mm.append(f.next()) # access next match and add to mm
  print f.hasNext() # is False, because f is empty now

  f.destroy() # release the memory used by finder

to:
  ...
  mm = list(f.find(img))

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Tsung-Hsiang Chang (vgod) said :
#1

Finder.destroy is not needed anymore in Sikuli X. The doc should be updated and noted that only Sikuli 0.10 needs Finder.destroy.

Revision history for this message
RaiMan (raimund-hocke) said :
#2

@ anatoly:
the second example is written this way intentionally to give newbees a chance, to understand the magic behind.

But thanks for your comment: I will add some more examples that use shorter forms and even integrate sorting of the returned matches.

And the docs have to be synchronized with findAll().

Revision history for this message
RaiMan (raimund-hocke) said :
#3

answered

Revision history for this message
anatoly techtonik (techtonik) said :
#4

Welcome back, I have a patch to start with. No time to polish though.

Revision history for this message
anatoly techtonik (techtonik) said :
#5

Can you help with this problem?

Provide an answer of your own, or ask anatoly techtonik for more information if necessary.

To post a message you must log in.