iterator API for glob
timotheecour4 opened this issue · 2 comments
timotheecour4 commented
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.
timotheecour4 commented
nevermind, that's what iglob is for
facelessuser commented
Yep, it was modeled after Python's internal glob in that sense.