Skip to content

Instantly share code, notes, and snippets.

View 1st1's full-sized avatar

Yury Selivanov 1st1

View GitHub Profile
import asyncio
import time
WARMUP_RUNS = 5
BENCH_RUNS = 20
FACTOR = 200
num_tasks = 0
{
scene_max_dpr: 1,
scene_max_samples: 3,
scene_camera_fov: 55,
scene_camera_rot: { x: 0, y: 0, z: 0 },
scene_camera_pos: { x: 0, y: 0, z: 5 },
bg_nspace: 7,
bg_lines: 2,
bg_line_size_vari: { min: 0.3, max: 0.8 },
bg_line_brightness: 87.04,
const buf = Buffer.allocUnsafe(16);
function f1(buf) {
return (
buf.slice(0, 4).toString("hex") +
"-" +
buf.slice(4, 6).toString("hex") +
"-" +
buf.slice(6, 8).toString("hex") +
"-" +
@1st1
1st1 / ag.py
Created October 22, 2019 21:39
import time
import threading
def generator():
try:
print('STARTED')
time.sleep(5)
yield 1
finally:
import pyrsistent
import immutables
import time
I = 1000000
KEY = '5'
for N in [5, 10, 20, 30, 100, 200, 300, 400, 500, 1000]:
print('=============')
@1st1
1st1 / ds.py
Created October 10, 2018 19:27
LRUIndex & MappedDeque datastructures
#
# This source file is part of the EdgeDB open source project.
#
# Copyright 2016-present MagicStack Inc. and the EdgeDB authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
@1st1
1st1 / fix.diff
Created October 1, 2018 15:41
Fix bpo-34769
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
index 492e377d09..3b1ed00af3 100644
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -477,10 +477,7 @@ class BaseEventLoop(events.AbstractEventLoop):
def _asyncgen_finalizer_hook(self, agen):
self._asyncgens.discard(agen)
if not self.is_closed():
- self.create_task(agen.aclose())
- # Wake up the loop if the finalizer was called from
@1st1
1st1 / avg.pyx
Created September 28, 2018 17:03
rolling average
#
# This source file is part of the EdgeDB open source project.
#
# Copyright 2016-present MagicStack Inc. and the EdgeDB authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
@1st1
1st1 / fix_dataclass_introspection.diff
Last active September 23, 2018 16:40
A hack-ish way to fix dataclasses & get_type_hints()
diff --git a/Lib/dataclasses.py b/Lib/dataclasses.py
index 28e9f75127..ad3dc46b67 100644
--- a/Lib/dataclasses.py
+++ b/Lib/dataclasses.py
@@ -868,7 +868,7 @@ def _process_class(cls, init, repr, eq, order, unsafe_hash, frozen):
# Include InitVars and regular fields (so, not ClassVars).
flds = [f for f in fields.values()
if f._field_type in (_FIELD, _FIELD_INITVAR)]
- _set_new_attribute(cls, '__init__',
+ had_own_init = _set_new_attribute(cls, '__init__',
@1st1
1st1 / mod_getattr.patch
Last active September 6, 2018 21:20
Backport PEP 562 module-level __getattr__ to Python 2.7
diff --git a/Lib/test/bad_getattr.py b/Lib/test/bad_getattr.py
new file mode 100644
index 0000000000..b4f790f3bf
--- /dev/null
+++ b/Lib/test/bad_getattr.py
@@ -0,0 +1,3 @@
+x = 1
+
+__getattr__ = "Surprise!"
diff --git a/Lib/test/bad_getattr2.py b/Lib/test/bad_getattr2.py