This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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) |