This file contains hidden or 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 threading | |
from ctypes import cdll | |
lib = cdll.LoadLibrary('./liblib.so') | |
class Foo(object): | |
def __init__(self): | |
self.obj = lib.Foo_new() | |
def bar(self): |
This file contains hidden or 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 redis | |
import time | |
import json | |
r = redis.Redis(host='localhost', port=6379, db=0) | |
for i in range(100): | |
print(i) | |
r.rpush('tasks', json.dumps({'task': i})) | |
time.sleep(0.5) |
This file contains hidden or 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 redis | |
import time | |
import json | |
r = redis.Redis(host='localhost', port=6379, db=0) | |
for i in range(100): | |
print(i) | |
r.rpush('tasks', json.dumps({'task': i})) | |
time.sleep(0.5) |
This file contains hidden or 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 asyncio | |
async def main(): | |
print('start') | |
async def on_stop(): | |
try: | |
await asyncio.sleep(10**10) | |
except asyncio.CancelledError: | |
pass |
This file contains hidden or 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
Type Trial 1 Trial 2 Trial 3 | |
%: 0.273233943000 0.268914790000 0.273714235000 | |
str.format(): 0.7942503730000681 0.793637686999773 0.7926878570001463 | |
str.Template(): 3.3321329630002765 3.3256752329998562 3.315622544999769 | |
f-string: 0.1914799450000828 0.18900782099990465 0.19004946999984895 |
This file contains hidden or 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
7a8,9 | |
> import hashlib | |
> | |
48a51 | |
> self.lcache = {} | |
449c452 | |
< return json.dumps({'id': identifier, 'results': _definitions}) | |
--- | |
> return json.dumps(_definitions) | |
560,565c563,584 |
This file contains hidden or 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
{ | |
# comments are useful | |
# specify rate in requests/second | |
"rate": 1000 | |
// maybe you prefer js style comments | |
/* or if you feel old fashioned */ | |
# key names do not need to be placed in quotes | |
key: "value" |
This file contains hidden or 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
class Connect(object): | |
def describe(self): | |
return some_code2(self) | |
def check(self): | |
r = self.describe() | |
return some_code3(self, r) | |
def find(self): | |
r = some_code1(self) |
This file contains hidden or 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
-O3 | |
* C: 100% (~1.14sec) | |
* C++: 99.73% | |
* C++ exception: 84.6% | |
-O2 | |
* C: 100% (~2.12sec) | |
* C++: 100.51% | |
* C++ exception: 74.02% |
This file contains hidden or 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 sqlalchemy import * | |
from sqlalchemy.orm import sessionmaker | |
from sqlalchemy.ext.declarative import declarative_base | |
Base = declarative_base() | |
engine = create_engine(connection_args) | |
metadata = MetaData(bind=engine) | |
class Tblname(Base): | |
__table__ = Table('tblname', metadata, autoload=True) |