Skip to content


Perf Logo

Don't frustrate people by building slow software, build software, and let Perf monitor performance.

Detected Patterns

Here are the patterns the tool recognises, and how to fix them.

Enumeration - Slow Duplicate Checking

You are using a slow way of duplicate checking between 2 lists. Use this instead.

String Joining

Joining strings can be very slow, even when the strings are small.


mystring += "other string"
string = string1 + string2


myvar = 2

string = "some variable: %s" % str(myvar)
myname = "Reece"
mylastname = "Dunham"

# .join is way faster then a lot of methods commonly used!
myfullname = " ".join([myname, mylastname])


Every time you import a module in Python, a process is run that essentially pulls the module in. The only problem with it is that it has to actually pull all the methods in, which can be time consuming. For example, here is the result of trying to import a few well known and widely used packages:

>>> import timeit
>>> timeit.timeit("import sys")
>>> timeit.timeit("import os")
>>> timeit.timeit("import six")
>>> timeit.timeit("import sys, os")
>>> timeit.timeit("import os, sys, six")

As you can see, just importing 3 packages can take a full second!

So when possible, you should limit the number of imports you have. Any file that has more then 15 will be flagged by Perf.


The source can be found on GitHub.

Last update: 2020-05-25