Собрали в одном месте самые важные ссылки
консультируем про IT, Python
from django.db import models from django_enums import enum class MyEnum(enum.Enum): __order__ = 'FOO BAR FOOBAR' # for python 2 FOO = ('f', 'Foo') BAR = ('b', 'Bar') FOOBAR = ('fb', 'FooBar') class MyModel(models.Model): enum_field = enum.EnumField( MyEnum, # required default=MyEnum.FOO, # optional )
Используются аннотации и модуль typing. Т.е. только для 3.3+
@yoton.cache(key_pattern="dummy_cache_key", expire_seconds=60)
def dummy_func():
return "hello"
>> dummy_func() # call the function
"hello" set in the cache
In [1]: import pylibmc In [2]: client = pylibmc.Client(['127.0.0.1'], binary=True) In [3]: client[b'key'] = b'value' In [4]: %timeit client[b'key'] 10000 loops, best of 3: 25.4 µs per loop In [5]: import diskcache as dc In [6]: cache = dc.Cache('tmp') In [7]: cache[b'key'] = b'value' In [8]: %timeit cache[b'key'] 100000 loops, best of 3: 11.8 µs per loop