Марк Коренберг <socketp...@gmail.com> added the comment:
> Glibc's readdir() and readdir_r() already do caching Yes, but glibc's readdir is the C analogue of python's generator. We do not need to create cache for cached values. I think it's OK to make python's generator on top of readdir (instead of getdents). Why not to create generator like this? (pseudocode) ------------------ DIR *d; struct dirent* entry, *e; entry = malloc(offsetof(struct dirent, d_name) + pathconf(dirpath, _PC_NAME_MAX) + 1); if (!e) raise Exception(); if (!(d= opendir(dirname))) { free(e) raise IOException(); } for (;;) { if (readdir_r(d, entry, &e)) { closedir(d); free(entry); raise IOException(); } if (!e) break; yield e; } closedir(d); free(entry); ------------------ ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue11406> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com