Staging
v0.5.1
https://foss.heptapod.net/mercurial/hgview
Revision 37ea02443274dfccbc9682e6f6125fa26c693b71 authored by Alain Leufroy on 05 July 2012, 15:35:51 UTC, committed by Alain Leufroy on 05 July 2012, 15:35:51 UTC
With python2.7, ``pygments`` loads the ``pkg_resources`` module which try to load a CPython3.3
module. This cause troubles as the lazy import system do not raise the expected
ImportError exception on python2.7.
1 parent e766475
Raw File
Tip revision: 37ea02443274dfccbc9682e6f6125fa26c693b71 authored by Alain Leufroy on 05 July 2012, 15:35:51 UTC
[lib] fix: do not lazy import missing modules (closes #99402)
Tip revision: 37ea024
decorators.py
# -*- coding: utf-8 -*-
"""
Some useful decorator functions
"""
import time

def timeit(func):
    """Decorator used to time the execution of a function"""
    def timefunc(*args, **kwargs):
        """wrapper"""
        t_1 = time.time()
        t_2 = time.clock()
        res = func(*args, **kwargs)
        t_3 = time.clock()
        t_4 = time.time()
        print "%s: %.2fms (time) %.2fms (clock)" % \
              (func.func_name, 1000*(t_3 - t_2), 1000*(t_4 - t_1))
        return res
    return timefunc
back to top