facelessuser/wcmatch

iterator API for glob

timotheecour4 opened this issue · 2 comments

Having an iterator interface (eg as controlled by a flag) instead of returning a list would enable more flexibility, performance and significantly less memory usage, eg in cases where you want to stop iterating when some condition is met (eg number of files, whether a specific file was found etc):

for a in glob.glob('**', flags=is_iterator):
  if is_done: break

This could be implemented using yield instead of appending to a returned list.

nevermind, that's what iglob is for

Yep, it was modeled after Python's internal glob in that sense.