This file contains 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
SETUP=" | |
import sys | |
from itertools import compress | |
def vprimes(maximum=10**6): | |
maxidx = maximum//2 | |
sieve = [True] * maxidx # 2, 3, 5, 7... might be prime | |
j = 0 | |
for i in range(1, int(maxidx**0.5)+1): |
This file contains 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
def false(false): | |
return false(false) | |
@false | |
def false(false=𝔽𝕒𝕝𝕤𝕖): | |
class false: | |
def __bool__(self): | |
if 𝔽𝕒𝕝𝕤𝕖: | |
nonlocal false | |
try: |
This file contains 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
# Yes, you can have apostrophes in your identifiers. | |
Shellyʼs = ["balloon"] | |
Johnʼs = [] | |
Johnʼs.extend(Shellyʼs.pop()) | |
Shellyʼs | |
Johnʼs |
This file contains 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
""" | |
A small 1-to-1 dictionary library. Shares inspiration from bidict: | |
https://pypi.python.org/pypi/bidict/0.1.1 | |
Implementation similarities are mostly coincidental. The ordered variant | |
was an idea stolen from | |
https://bitbucket.org/jab/bidict/issue/1/ordereddict-integration |
This file contains 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 timeit import Timer | |
from functools import partial | |
def add_string(n): | |
s = '' | |
for _ in range(n): | |
s += ' ' | |
def add_string_in_list(n): | |
l = [''] |
This file contains 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
/// | |
/// The class to hold an object's information so that the Engine can | |
/// manipulate it. | |
/// | |
/// | |
/// | |
class Object { | |
protected: | |
/// | |
/// The object's renderable component |
This file contains 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 sys | |
import numpy | |
import numexpr | |
numexpr.set_num_threads(2) | |
CHUNKS = 256 | |
def mandel_unroll_numexpr(n, z="z", c="c"): | |
""" | |
Generate a numexpr for the core mandelbrot loop (z = z ** 2 + c) |
This file contains 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
*** Error in `python': free(): invalid pointer: 0x00007fd64024d530 *** | |
======= Backtrace: ========= | |
/usr/lib/libc.so.6(+0x73f8e)[0x7fd65c1dcf8e] | |
/usr/lib/libc.so.6(+0x7988e)[0x7fd65c1e288e] | |
/usr/lib/libc.so.6(+0x7a04b)[0x7fd65c1e304b] | |
/usr/lib/python3.4/site-packages/numpy/core/multiarray.cpython-34m.so(+0xc842c)[0x7fd65ad1242c] | |
/usr/lib/python3.4/site-packages/numexpr/interpreter.cpython-34m.so(_Z11NumExpr_runP13NumExprObjectP7_objectS2_+0xc58b)[0x7fd652d8f68b] | |
/usr/lib/libpython3.4m.so.1.0(PyObject_Call+0x88)[0x7fd65c797e68] | |
/usr/lib/libpython3.4m.so.1.0(PyEval_EvalFrameEx+0x1091)[0x7fd65c846721] | |
/usr/lib/libpython3.4m.so.1.0(PyEval_EvalCodeEx+0x879)[0x7fd65c84e289] |
This file contains 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
#include <iostream> | |
#include <iterator> | |
#include <numeric> | |
#include <unordered_set> | |
#include <vector> | |
int32_t some_calculations(int32_t number) { | |
std::vector<int32_t> a; | |
std::unordered_set<int32_t> s; |
This file contains 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
#include <iostream> | |
#include <iterator> | |
#include <numeric> | |
#include <unordered_set> | |
#include <vector> | |
int32_t some_calculations(int32_t number) { | |
std::vector<int32_t> a; | |
std::unordered_set<int32_t> s; | |