Permalink
Browse files

strict pep8 compliance

  • Loading branch information...
1 parent d017747 commit f825408988b2f6fbe93e2ca4d2ec0584390b4ea7 @cyberdelia cyberdelia committed Jun 13, 2012
Showing with 22 additions and 20 deletions.
  1. +12 −15 setup.py
  2. +10 −5 statprof.py
View
@@ -1,27 +1,24 @@
#!/usr/bin/env python
+import sys
-import os, sys
from setuptools import setup
-def read(fname):
- return open(os.path.join(os.path.dirname(__file__), fname)).read()
-
extra = {}
if sys.version_info >= (3,):
extra['use_2to3'] = True
setup(
- name = "statprof",
- version = "0.1.2",
- author = "Bryan O'Sullivan",
- author_email = "bos@serpentine.com",
- description = "Statistical profiling for Python",
- license = "LGPL",
- keywords = "profiling",
- url = "http://packages.python.org/statprof",
- py_modules = ['statprof'],
- long_description = read('README.rst'),
- classifiers = [
+ name="statprof",
+ version="0.1.2",
+ author="Bryan O'Sullivan",
+ author_email="bos@serpentine.com",
+ description="Statistical profiling for Python",
+ license="LGPL",
+ keywords="profiling",
+ url="http://packages.python.org/statprof",
+ py_modules=['statprof'],
+ long_description=open('README.rst').read(),
+ classifiers=[
"Development Status :: 3 - Alpha",
"Topic :: Utilities",
"License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)",
View
@@ -135,10 +135,10 @@ def reset(self, frequency=None):
self.sample_count = 0
# a float
if frequency:
- self.sample_interval = 1.0/frequency
+ self.sample_interval = 1.0 / frequency
elif not hasattr(self, 'sample_interval'):
# default to 1000 Hz
- self.sample_interval = 1.0/1000.0
+ self.sample_interval = 1.0 / 1000.0
else:
# leave the frequency as it was
pass
@@ -155,6 +155,7 @@ def accumulate_time(self, stop_time):
state = ProfileState()
+
class CodeKey(object):
cache = {}
@@ -186,6 +187,7 @@ def get(cls, frame):
cls.cache[k] = v
return v
+
class CallData(object):
all_calls = {}
@@ -223,6 +225,7 @@ def sample_stack_procs(frame):
for key in keys_seen:
CallData.get(key).cum_sample_count += 1
+
def profile_signal_handler(signum, frame):
if state.profile_level > 0:
state.accumulate_time(clock())
@@ -238,6 +241,7 @@ def profile_signal_handler(signum, frame):
def is_active():
return state.profile_level > 0
+
def start():
'''Install the profiling signal handler, and start profiling.'''
state.profile_level += 1
@@ -248,7 +252,8 @@ def start():
signal.signal(signal.SIGPROF, profile_signal_handler)
signal.setitimer(signal.ITIMER_PROF,
rpt or state.sample_interval, 0.0)
- state.gc_time_taken = 0 # dunno
+ state.gc_time_taken = 0 # dunno
+
def stop():
'''Stop profiling, and uninstall the profiling signal handler.'''
@@ -259,7 +264,8 @@ def stop():
rpt = signal.setitimer(signal.ITIMER_PROF, 0.0, 0.0)
signal.signal(signal.SIGPROF, signal.SIG_IGN)
state.remaining_prof_time = rpt[0]
- state.gc_time_taken = 0 # dunno
+ state.gc_time_taken = 0 # dunno
+
def reset(frequency=None):
'''Clear out the state of the profiler. Do not call while the
@@ -336,4 +342,3 @@ def display(fp=None):
print >> fp, ('---')
print >> fp, ('Sample count: %d' % state.sample_count)
print >> fp, ('Total time: %f seconds' % state.accumulated_time)
-

0 comments on commit f825408

Please sign in to comment.