Message130286
> 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);
------------------ |
|
Date |
User |
Action |
Args |
2011-03-07 19:43:56 | socketpair | set | recipients:
+ socketpair, loewis, pitrou, giampaolo.rodola, Trundle, nvetoshkin, neologix |
2011-03-07 19:43:56 | socketpair | set | messageid: <1299527036.3.0.913790438649.issue11406@psf.upfronthosting.co.za> |
2011-03-07 19:43:54 | socketpair | link | issue11406 messages |
2011-03-07 19:43:54 | socketpair | create | |
|