Skip to content

Instantly share code, notes, and snippets.

@djv
djv / line_profiler_decorator.py
Created October 9, 2018 20:17 — forked from pavelpatrin/line_profiler_decorator.py
Python line profiler decorator
def profile(func):
from functools import wraps
@wraps(func)
def wrapper(*args, **kwargs):
from line_profiler import LineProfiler
prof = LineProfiler()
try:
return prof(func)(*args, **kwargs)
finally:
{-# LANGUAGE BangPatterns #-}
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as UV
import qualified Data.ByteString.Char8 as C
import Data.Vector.Strategies
data LabelPixel = LabelPixel {_label :: !Int, _pixels :: !(UV.Vector Int)}
trim :: C.ByteString -> C.ByteString
trim = C.reverse . C.dropWhile (`elem` " \t") . C.reverse . C.dropWhile (`elem` " \t")
{-# LANGUAGE GADTs, StandaloneDeriving #-}
data List a b where
Nil :: List a b
ConsI :: Int -> List Bool Int -> List Int Bool
ConsB :: Bool -> List Int Bool -> List Bool Int
deriving instance (Show a, Show b) => Show (List a b)