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
import re, sys, os | |
from datetime import datetime | |
from collections import defaultdict | |
class Request(): | |
def __init__(self, id, start): | |
self.id = id | |
self.start = start |
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
from gevent import http | |
import psyco_gevent | |
psyco_gevent.make_psycopg_green() | |
from psycopg2.pool import SimpleConnectionPool | |
dsn = 'dbname=test host=127.0.0.1 port=5433 user=test password=123' | |
dbpool = SimpleConnectionPool(10,15,dsn) | |
def handler(request): | |
if request.uri.startswith('/recall/'): |
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
import cPickle as pickle | |
import numpy as np | |
import StringIO | |
import time | |
import zlib | |
a = np.array(range(100000)) | |
b = np.array(range(200000, 300000)) | |
file_obj = StringIO.StringIO() | |
start = time.time() |
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
cPickle default dumps: 0.107237100601 | |
cPickle HIGHEST_PROTOCOL dumps: 0.0678668022156 | |
marshal dumps: 0.0203359127045 | |
cPickle default loads: 0.0411729812622 | |
cPickle HIGHEST_PROTOCOL loads: 0.0352649688721 | |
marshal loads: 0.0221829414368 |
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
marshal dumps: 0.0218579769135 | |
marshal dumps with base64: 0.0708141326904 | |
marshal dumps with binascii: 0.0610530376434 | |
marshal loads: 0.0211379528046 | |
marshal loads with base64: 0.0429949760437 | |
marshal loads with base64: 0.0391380786896 |
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 load_obj(data): | |
try: | |
return cPickle.loads(zlib.decompress(data)) | |
except zlib.error: | |
return cPickle.loads(data) | |
def dump_obj(obj): | |
# In [24]: %timeit zlib.compress(cPickle.dumps(a, protocol=cPickle.HIGHEST_PROTOCOL), 1) | |
# 1000 loops, best of 3: 1.74 ms per loop |
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
import multiprocessing | |
import time | |
a, b = multiprocessing.Pipe() | |
def func(conn): | |
while True: | |
conn.recv() | |
p = multiprocessing.Process(target=func, args=(b,)) |
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
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: webapp | |
spec: | |
selector: | |
matchLabels: | |
app: webapp | |
replicas: 2 | |
template: |