This file contains hidden or 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
MariaDB [fun]> SELECT * FROM names; | |
+----+------------+------------+ | |
| id | first_name | last_name | | |
+----+------------+------------+ | |
| 1 | Batista | Harahap | | |
| 2 | Rinto | Harahap | | |
| 3 | Michael | Jordan | | |
| 4 | Chris | Martin | | |
| 5 | Jordan | Sparks | | |
| 6 | Daniel | Craig | |
This file contains hidden or 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
$ python cythondemo.py | |
Elapsed Time: 3.86 second | |
Ops/second: 25903031.00 |
This file contains hidden or 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 cpuload import load | |
import time | |
if __name__ == '__main__': | |
max = 100000000 | |
_start = time.time() | |
load(10, max) | |
_end = time.time() |
This file contains hidden or 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
$ python setup.py build_ext --inplace | |
running build_ext | |
building 'cythondemo' extension | |
cc -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c cythondemo.c -o build/temp.macosx-10.11-intel-2.7/cythondemo.o | |
cythondemo.c:2531:28: warning: unused function '__Pyx_PyObject_AsString' | |
[-Wunused-function] | |
static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) { | |
^ | |
cythondemo.c:2528:32: warning: unused function '__Pyx_PyUnicode_FromString' | |
[-Wunused-function] |
This file contains hidden or 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 setuptools import setup, Extension | |
setup(ext_modules=[Extension("cpuload", ["cpuload.c"])], | |
name='cpuload', | |
version='0.0.1', | |
description='A simple Cython demo', | |
long_description='A simple Cython demo', | |
keywords='cython demo', | |
author='Batista Harahap', |
This file contains hidden or 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
$ pip install cython | |
$ cython cpuload.py | |
$ ls -la cpuload.* | |
... | |
-rw-r--r-- 1 tista staff 131178 Aug 28 18:58 cpuload.c | |
-rw-r--r-- 1 tista staff 76 Aug 28 18:58 cpuload.py | |
... |
This file contains hidden or 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
$ python cpuload.py | |
Elapsed Time: 7.68 second | |
Ops/second: 13018765.56 |
This file contains hidden or 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 time | |
def load(number, max): | |
for x in xrange(1, max): | |
number*number*x | |
if __name__ == '__main__': | |
max = 100000000 | |
_start = time.time() |
This file contains hidden or 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
MariaDB [fun]> SELECT COUNT(DISTINCT last_name) AS cardinality FROM users; | |
+-------------+ | |
| cardinality | | |
+-------------+ | |
| 9 | | |
+-------------+ |
This file contains hidden or 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
MariaDB [fun]> SELECT * FROM users; | |
+----+------------+------------+ | |
| id | first_name | last_name | | |
+----+------------+------------+ | |
| 1 | Batista | Harahap | | |
| 2 | Rinto | Harahap | | |
| 3 | Michael | Jordan | | |
| 4 | Chris | Martin | | |
| 5 | Jordan | Sparks | | |
| 6 | Daniel | Craig | |