python2.7 compat

line-profiler showed that most of the time is spent on line 47

Signed-off-by: Andrew Tselischev <andrewtselischev@gmail.com>