Skip to content

Instantly share code, notes, and snippets.

🐍
▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀ꜚ

Ethan Smith ethanhs

🐍
▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀ꜚ
View GitHub Profile
@ethanhs
ethanhs / example.rs
Last active Feb 26, 2020
Example using pickling in pyo3
View example.rs
#![feature(arbitrary_self_types)]
use pyo3::prelude::*;
use pyo3::pyclass::PyClassShell;
use pyo3::types::{PyBytes, PyTuple};
use pyo3::ToPyObject;
use bincode::{deserialize, serialize};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
@ethanhs
ethanhs / pypitest.log
Last active Feb 18, 2020
running pegen on pypi's top 4000 packages
View pypitest.log
This file has been truncated, but you can view the full file.
pegen/pegen.c:101:1: warning: ‘token_name’ defined but not used [-Wunused-function]
token_name(int type)
^~~~~~~~~~
pegen/parse_string.c: In function ‘FstringParser_ConcatFstring’:
pegen/parse_string.c:604:24: warning: ‘expr’ may be used uninitialized in this function [-Wmaybe-uninitialized]
return expr->v.Expr.value;
~~~~~~~~~~~~^~~~~~
pegen/parse_string.c:584:13: note: ‘expr’ was declared here
stmt_ty expr = asdl_seq_GET(mod->v.Module.body, 0);
@ethanhs
ethanhs / output.log
Created Feb 28, 2019
Trying to build typed_ast with pypy
View output.log
ethanhs▶~\Documents\typed_ast◇master❯ ..\..\Downloads\pypy3.6-v7.0.0-win32\pypy3 -m pip install .
Processing c:\users\ethanhs\documents\typed_ast
Installing collected packages: typed-ast
Running setup.py install for typed-ast ... error
Complete output from command C:\Users\ethanhs\Downloads\pypy3.6-v7.0.0-win32\pypy3.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\ethanhs\\AppData\\Local\\Temp\\pip-req-build-13ik00j7\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\ethanhs\AppData\Local\Temp\pip-record-qn2gezr2\install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build\lib.win32-3.6
creating build\lib.win32-3.6\typed_ast
@ethanhs
ethanhs / client.py
Last active Oct 24, 2018
An experiment writing nice wrappers around namedpipes using the _winapi module.
View client.py
import time
import sys
from namedpipe import *
if __name__ == '__main__':
if len(sys.argv) < 2:
print("need s or c as argument")
elif sys.argv[1] == "s":
with NamedPipeServer('testFoo') as server:
count = 10
while count > 0:
@ethanhs
ethanhs / py-spy-mypy
Created Oct 18, 2018
Running py-spy on mypy
View py-spy-mypy
Collecting samples from 'python -m mypy mypy' (python v3.7.0)
Total Samples 4700
GIL: 0.00%, Active: 32.00%, Threads: 1
%Own %Total OwnTime TotalTime Function (filename:line)
8.50% 8.50% 1.77s 1.82s atomic_write (C:\Users\ethanhs\Documents\mypy\mypy\build.py:866)
1.00% 9.50% 0.190s 2.78s __eq__ (C:\Users\ethanhs\Documents\mypy\mypy\types.py:532)
1.00% 1.00% 0.025s 0.085s check_arg (C:\Users\ethanhs\Documents\mypy\mypy\checkexpr.py:1163)
1.00% 3.50% 0.190s 1.19s __hash__ (C:\Users\ethanhs\Documents\mypy\mypy\types.py:527)
0.50% 9.50% 0.045s 3.76s literal_hash (C:\Users\ethanhs\Documents\mypy\mypy\literals.py:93)
@ethanhs
ethanhs / singledispatchmethod.py
Created Apr 25, 2018
`functools.singledispatchmethod` for use before 3.8
View singledispatchmethod.py
from functools import singledispatch, update_wrapper
class singledispatchmethod:
"""Single-dispatch generic method descriptor.
Supports wrapping existing descriptors and handles non-descriptor
callables as instance methods.
"""
def __init__(self, func):
if not callable(func) and not hasattr(func, "__get__"):
@ethanhs
ethanhs / output.log
Created Mar 6, 2018
Changing default python version in mypy
View output.log
Worker information
hostname: 26f6015e-26d2-496e-a5c1-f4148fa0eb71@1.i-0198d17-production-2-worker-org-ec2.travisci.net
version: v3.5.0 https://github.com/travis-ci/worker/tree/77dbc57c72d00592aeb754773b712da843c7e00d
instance: 24be829 travisci/ci-garnet:packer-1512502276-986baf0 (via amqp)
startup: 417.936957ms
mode of ‘/usr/local/clang-5.0.0/bin’ changed from 0777 (rwxrwxrwx) to 0775 (rwxrwxr-x)
system_info
Build system information
Build language: python
Build group: stable
View keybase.md

Keybase proof

I hereby claim:

  • I am ethanhs on github.
  • I am ethanhs (https://keybase.io/ethanhs) on keybase.
  • I have a public key ASB62E5i52bI_UgYyZyjrivJLeaf9qTzpAD4vITJ7-7dtAo

To claim this, I am signing this object:

View build log with flake.log
travis_fold:start:worker_info
Worker information
hostname: 38bd253f-48d2-4d66-b916-0779d5cf1f1f@1.i-05f7a68-production-2-worker-org-ec2.travisci.net
version: v3.5.0 https://github.com/travis-ci/worker/tree/77dbc57c72d00592aeb754773b712da843c7e00d
instance: 355a358 travisci/ci-garnet:packer-1512502276-986baf0 (via amqp)
startup: 463.749498ms
travis_fold:end:worker_info
mode of ‘/usr/local/clang-5.0.0/bin’ changed from 0777 (rwxrwxrwx) to 0775 (rwxrwxr-x)
travis_fold:start:system_info
Build system information
@ethanhs
ethanhs / my_first_calc.c.py
Created Oct 20, 2017
Because we need a C version
View my_first_calc.c.py
MAX = 250
nums = range(MAX + 1)
signs = '+-*/'
if_template = '''
if (a == {0} && b == '{1}' && c == {2})
puts("{0} {1} {2} = {3}");
'''
main_template = '''
You can’t perform that action at this time.