Skip to content

Instantly share code, notes, and snippets.

View Tinche's full-sized avatar

Tin Tvrtković Tinche

View GitHub Profile
> cat test.py
from contextlib import contextmanager
@contextmanager
def polite():
print("Hi!")
yield
print("Bye!")
@polite
> pip install configparser --no-compile
Downloading/unpacking configparser
Using download cache from /home/tin/.cache/pip/https%3A%2F%2Fpypi.python.org%2Fpackages%2Fsource%2Fc%2Fconfigparser%2Fconfigparser-3.3.0r2.tar.gz
Running setup.py (path:/home/tin/pg/cp-pypy/build/configparser/setup.py) egg_info for package configparser
Installing collected packages: configparser
Running setup.py install for configparser
deleting configparser.egg-info/requires.txt
error: <fdopen>: Bad file descriptor
"""Cached property multithreading test."""
from threading import Lock, Thread
from time import sleep
from cached_property import cached_property
COUNT = 0
COUNT_LOCK = Lock()
NUM_THREADS = 10
class Test(object):
### Keybase proof
I hereby claim:
* I am Tinche on github.
* I am tinche (https://keybase.io/tinche) on keybase.
* I have a public key whose fingerprint is B063 23B0 E68E 64DE 7EF6 29DA 88B0 B079 6949 65D8
To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am tinche on github.
  • I am tinche (https://keybase.io/tinche) on keybase.
  • I have a public key whose fingerprint is 7BD5 6290 52BC 9DDF 8D20 3A90 FBAD 9430 9989 8647

To claim this, I am signing this object:

@Tinche
Tinche / cpu info
Created July 24, 2013 19:22
Desktop CPU info
cat /proc/cpuinfo
processor : 0
vendor_id : AuthenticAMD
cpu family : 16
model : 10
model name : AMD Phenom(tm) II X6 1055T Processor
stepping : 0
microcode : 0x10000dc
cpu MHz : 2800.000
cache size : 512 KB
.
├── bin
├── glide.lock
├── glide.yaml
├── src
│   └── tin
│   └── hello.go
└── vendor
├── github.com
│   └── codegangsta
> cat t.py
class A:
__slots__ = ('x', 'y', 'z', 'a', 'b', 'c')
def __init__(self, x, y, z, a, b, c):
#_setattr = object.__setattr__.__get__(self, A)
_setattr = object.__setattr__
_setattr('x', x)
_setattr('y', y)
_setattr('z', z)
_setattr_cached = object.__setattr__
class A:
__slots__ = ('x', 'y', 'z', 'a', 'b', 'c')
def __init__(self, x, y, z, a, b, c):
_setattr = _setattr_cached.__get__(self, A)
_setattr('x', x)
_setattr('y', y)
_setattr('z', z)
import attr
import pickle
@attr.s(frozen=True)
class A(object):
x = attr.ib()
@attr.s(slots=True)
class B(object):