Skip to content

Instantly share code, notes, and snippets.

View mrvaldes's full-sized avatar
🌴

Matias Valdes mrvaldes

🌴
View GitHub Profile
@Skinner927
Skinner927 / classproperty.py
Last active October 12, 2020 23:01
Properties for Python Classes. Supports get and set.
"""
To use simply copy ClassPropertyMeta and classproperty into your project
"""
class ClassPropertyMeta(type):
def __setattr__(self, key, value):
obj = self.__dict__.get(key, None)
if type(obj) is classproperty:
return obj.__set__(self, value)
@Integralist
Integralist / profile_ctx.py
Last active June 7, 2020 15:20 — forked from andriykohut/profile_ctx.py
[Python profiling context management] #python #profiling #performance
import cProfile
import contextlib
import io
import pstats
import sys
import timeit
@contextlib.contextmanager
def prof(*restrictions, stdout=True, dump=None, sortby='cumulative'):
@davesque
davesque / profile.py
Created September 20, 2013 21:58
Simple profiling context manager
import cProfile
import contextlib
import os
@contextlib.contextmanager
def profile(filename='~/python.profile', *args, **kwargs):
profile = cProfile.Profile(*args, **kwargs)
profile.enable()