-
Notifications
You must be signed in to change notification settings - Fork 0
/
static.sh
executable file
·55 lines (42 loc) · 1.42 KB
/
static.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
#
# Usage:
# ./static.sh <function name>
set -o nounset
set -o pipefail
set -o errexit
source common.sh
# http://ptspts.blogspot.com/2014/06/whats-difference-between-staticpython.html
#
# - Another important difference is that with PyRun you can compile and install
# C extensions, and with StaticPython you can't (even ctypes doesn't work with
# StaticPython). However, many extensions are precompiled: Stackless + greenlet
# + libssl + Tokyo Cabinet + libevent2 + Concurrence + AES + Syncless +
# MessagePack + Gevent MySQL + PyCrypto.
#
# Yeah this is what I want. Except I want to eliminate the parser too!
# Is this a second static python?
# https://github.com/bendmorris/static-python
# http://mdqinc.com/blog/2011/08/statically-linking-python-with-cython-generated-modules-and-packages/
download() {
mkdir -p _static
wget --directory _static \
https://raw.githubusercontent.com/pts/staticpython/master/release/python2.7-static
chmod +x $STATIC_PY
}
readonly STATIC_PY=_static/python2.7-static
# 7.5 MB
static-stats() {
bin-stats $STATIC_PY
}
# Wow static Python actually starts slower! Probably because the stuff that
# would wait until dlopen() is done at initialization time?
startup-speed() {
# 7 ms vs 23 ms
time python -c 'print "hi"'
time $STATIC_PY -c 'print "hi"'
# 20 ms vs 51 ms
#time python -c 'import os, sys, re; print "hi"'
#time $STATIC_PY -c 'import os, sys, re; print "hi"'
}
"$@"