Skip to content

Instantly share code, notes, and snippets.

/// <reference path="../ext/jquery-1.12.4.js" />
/// <reference path="../ext/jquery-ui-1.12.1.js" />
"use strict";
function BlobLine(element, options) {
element = $(element);
this.numBlobs = options.numBlobs;
this.blobWidth = options.blobWidth;
this.blobHeight = options.blobHeight;
2
view 227 ns ± 8.56 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
array_copy_view 582 ns ± 37.8 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
array_int_index 1.38 µs ± 33.9 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
array_bool_index 1.85 µs ± 111 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
array_delete 5.45 µs ± 43.9 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
array_resize 7.8 µs ± 179 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
8
view 226 ns ± 8.13 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
array_copy_view 558 ns ± 17.8 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
Names:
MSeifert
MSeifert2
original1
original2
Coldspeed1
Coldspeed2
Chris_Rands
EvKounis
schumich
import timeit
timeit.timeit(
"""print('numpy' in sys.modules)
import numpy""", "import sys", number=3)
# False
# True
# True
# 0.3159413684456874
a = 99
if a == 1:
pass
elif a == 1:
pass
elif a == 2:
pass
elif a == 3:
pass
import line_profiler
def foo():
for i in range(10000):
a = i**i
if i % 1000 == 0:
print(i)
lp = line_profiler.LineProfiler()
lp.add_function(foo)
from collections import Mapping
cls = Mapping
subclass = dict
for scls in cls.__subclasses__():
if issubclass(subclass, scls):
cls._abc_cache.add(subclass)
print('found', scls)
break
from astropy.io import fits
import numpy as np
hdul = fits.HDUList(fits.PrimaryHDU(np.random.random((10, 10))))
hdul.writeto('tmp1.fits', overwrite=True)
from __future__ import division
import numpy as np
obj1 = fits.open('tmp1.fits')
data_obj1 = obj1[0].data
def double_evens1(inp):
for item in inp:
if not item % 2:
yield item
yield item
def double_evens2(inp):
for item in inp:
if not item % 2:
yield item
import timeit
def f_range(n):
for i in range(n):
pass
def f_xrange(n):
for i in xrange(n):
pass