Skip to content

Instantly share code, notes, and snippets.

View 1st1's full-sized avatar

Yury Selivanov 1st1

View GitHub Profile
import asyncio
from twisted.internet import asyncioreactor
asyncioreactor.install()
import treq
from twisted.internet.defer import Deferred, ensureDeferred
from twisted.internet.task import react
async def run():
@1st1
1st1 / fileio.py
Last active April 25, 2019 03:47
# in asyncio:
class asyncio.AbstractFileIOImplementation:
async def open(self):
raise NotImplementedError
async def open(...):
return await get_current_loop(). get_file_io_implementation().open(...)
  1. $ git clone https://github.com/MagicStack/immutables.git
  2. cd immutables
  3. wget https://gist.githubusercontent.com/1st1/57d979e1e58948a7e523754a3d02a57d/raw/8857aca8e0f13c804218540820993b6481cd6619/bench.py
  4. pypy3 bench.py -- observe the timings for "hamt"
  5. run pypy3 bench.py -- observe how "hamt" timings are way worse now
@1st1
1st1 / bench.py
Last active November 1, 2022 11:43
immutables benchmark
import pyrsistent
import immutables
import time
I = 1_000_000
KEY = '5'
for N in [5, 10, 20, 30, 100, 200, 300, 400, 500, 1000]:
print('=============')
diff --git a/configure b/configure
index 6ce0728af1..f82db5b684 100755
--- a/configure
+++ b/configure
@@ -16794,7 +16794,7 @@ fi
# no such luck; use some default ssldirs
if ! $found; then
- ssldirs="/usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr"
+ ssldirs="/usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /opt/local /usr"
@1st1
1st1 / contextvars
Created January 26, 2018 20:55
decimal bench
# ======================================================================
# Calculating pi, 10000 iterations
# ======================================================================
Precision: 9 decimal digits
float:
result: 3.1415926535897927
time: 0.056572s
@1st1
1st1 / sd.py
Last active December 20, 2017 01:57
sd.py
from functools import singledispatch
@singledispatch
def repr_png(arg):
if hasattr(type(arg), '__repr_png__'):
return type(arg).__repr_png__(arg)
raise
@1st1
1st1 / get_buffer_bench.py
Created December 8, 2017 01:47
get_buffer_bench.py
import struct
try:
from time import perf_counter as clock
except ImportError:
from time import time as clock
import asyncio
import uvloop
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
@1st1
1st1 / keybase.md
Created October 5, 2017 06:09
keybase.md

Keybase proof

I hereby claim:

  • I am 1st1 on github.
  • I am yselivanov (https://keybase.io/yselivanov) on keybase.
  • I have a public key ASAWQPbuPA-Vuv87Qrbf7ImOaZcKqQBnuGQsdhLLTw7KEQo

To claim this, I am signing this object:

@1st1
1st1 / stack.py
Created August 12, 2017 19:16
Context Stack (PEP 550)
import sys
class ContextStack:
def __init__(self, key):
self.key = key
def _get_level(self):
level_key = type(self), self.key