--- Neal Norwitz <[EMAIL PROTECTED]> wrote: > On 5/22/07, Steve Howell <[EMAIL PROTECTED]> > wrote: > > > > In the system I've worked on for the last three > years, > > we have at least 200 calls to the builtin open() > > method. > > This number is meaningless by itself. 200 calls in > how many lines of code? > How many files total and how many files use open? > > I'm not sure if the numbers are useful, but if it's > only used in 0.1% > of the modules, that's not a strong case for keeping > it. >
17.7% of the files I searched have calls to open(). 980 source files 174 files call open() 242898 lines of code 305 calls to open() This is the quick and dirty Python code to compute these stats, which has a call to the open() builtin. import os fns = [] for dir in ('/ts-qa51', '/ars-qa12', '/is-qa7'): cmd = "cd %s && find . -name '*.py'" % dir output = os.popen(cmd).readlines() fns += [os.path.join(dir, line[2:]) for line in output] fns = [fn.strip() for fn in fns] numSourceFiles = len(fns) print '%d source files' % numSourceFiles loc = 0 filesWithBuiltin = 0 openLines = 0 for fn in fns: fn = fn.strip() lines = open(fn).readlines() loc += len(lines) hasBuiltin = False for line in lines: if ' open(' in line: hasBuiltin = True openLines += 1 if hasBuiltin: filesWithBuiltin += 1 print '%d files call open()' % filesWithBuiltin print '%d lines of code' % loc print '%d calls to open()' % openLines ____________________________________________________________________________________Get the Yahoo! toolbar and be alerted to new email wherever you're surfing. http://new.toolbar.yahoo.com/toolbar/features/mail/index.php _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com