Skip to content

Commit

Permalink
Speedup creating Item objects (jendrikseipp#165)
Browse files Browse the repository at this point in the history
According to vmprof (https://github.com/vmprof/vmprof-python) over
a large code base, about 20% of the time was spent in Item:__init__,
use slots to reduce the time spent in Item:__init__ to 1%
  • Loading branch information
jogo authored and jendrikseipp committed Jul 15, 2019
1 parent fb501be commit fe494ec
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions vulture/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ class Item(object):
"""
Hold the name, type and location of defined code.
"""
__slots__ = ('name', 'typ', 'filename', 'first_lineno',
'last_lineno', 'message', 'confidence')

def __init__(self, name, typ, filename, first_lineno, last_lineno,
message='',
Expand Down

0 comments on commit fe494ec

Please sign in to comment.