[Bugs] [Bug 1175711] os.walk() vs scandir.walk() performance

bugzilla at redhat.com bugzilla at redhat.com
Tue Dec 23 14:54:04 UTC 2014


https://bugzilla.redhat.com/show_bug.cgi?id=1175711



--- Comment #2 from Prashanth Pai <ppai at redhat.com> ---
I did check that (using following script) on latest master branch code. It does
fill that.

#!/usr/bin/env python

# Return status indicates if d_type returned

import ctypes
import sys

(DT_UNKNOWN, DT_DIR,) = (0, 4,)

class dirent(ctypes.Structure):
  _fields_ = [
    ("d_ino", ctypes.c_long),
    ("d_off", ctypes.c_long),
    ("d_reclen", ctypes.c_ushort),
    ("d_type", ctypes.c_ubyte),
    ("d_name", ctypes.c_char*256)]

direntp = ctypes.POINTER(dirent)

libc = ctypes.cdll.LoadLibrary("libc.so.6")
libc.readdir.restype = direntp

dirp = libc.opendir(".")
if dirp:
  ep = libc.readdir(dirp)
else:
  sys.exit(1)

print ep.contents.d_type

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.


More information about the Bugs mailing list