Category Archives: python

high performance python tips

http://www.jeffknupp.com/blog/2013/06/30/pythons-hardest-problem-revisited/ Quoted from http://ict.swisscom.ch/2015/02/pyperformance/  I/O bound problems can make good use of multi-threading (where the GIL is released during I/O) or asynchronous programming. CPU-bound problems can be addressed by better algorithms (nothing beats an algorithm with less computational complexity), using … Continue reading

Posted in python | Tagged | Leave a comment

how to install pymssql

You need to install the FreeTDS development package (freetds-dev) before trying to install pymssql with pip: $ sudo apt-get install freetds-dev and then download and install the latest version of pymssql (don’t use pip install as the version in PyPi … Continue reading

Posted in mssql, pymssql, python, Uncategorized | Leave a comment

python_path SublimeRope

Please add the following lines on a project base. .rope/config.py prefs.add(‘python_path’, ‘/home/myhome/.virtualenvs/py27/lib/python2.7/site-packages’) prefs.add(‘python_path’,’/usr/lib/python2.7′)

Posted in python, sublime | Leave a comment

python for loop, iterator, iterable, generator

For Loop When Python executes the for loop, it first invokes the __iter__() method of the container to get the iterator of the container. It then repeatedly calls the next() method (__next__() method in Python 3.x) of the iterator until the iterator raises a StopIteration exception. Once the … Continue reading

Posted in python | Leave a comment

cProfile pstats

pstats

Posted in python | Leave a comment

osx python set up

Install Python from homebrew install homebrew: ruby <(curl -fsSkL raw.github.com/mxcl/homebrew/go) install latest Xcode ‘s command line tool from developer.apple.com. /usr/local/bin/pip install virtualenv virtualenvwapper brew install python python3   .bashrc export WORKON_HOME=$HOME/.virtualenvs source /usr/local/bin/virtualenvwrapper.sh mkvirtualenv -a /Users/vyang/src/app -r /Users/vyang/src/app/requirements.txt app

Posted in osx, python | Leave a comment

concurrency model with Actor

Actor model everything is a Actor, natively concurrent. Support in programming language Erlang: language level. Erlang is the best platform for concurrency and distributed application so far. Python eventlet why gevent Gevent: good, bad and ugly gevent tutorial Java: library level. Akka

Posted in erlang, eventlet, gevent, java, python | Leave a comment

Set up Python for Android development

Python Android adb cmd example Install android-sdk: tools:android platform-tools:adb Create an AVD (“android avd”) test1. “emulator avd test1” sudo apt-get install ia32-libs While the above is running, “platform-tools/adb install sl4a_r4.apk” While the above is running, “platform-tools/adb install PythonForAndroid_r4.apk” Use adb … Continue reading

Posted in android, python | Leave a comment

Python study notes

python overview abstraction:  type: dynamic binding, strong type(for catching bugs) object is first class:objects can be freely passed around, inspected, and placed in various data structures (e.g., lists or dictionaries) at run-time. organizing code: package, module, class,method, function.  flow control: … Continue reading

Posted in python | Leave a comment

cpython source code study note

http://www.python.org/dev/peps/pep-0339/ http://eli.thegreenplace.net/articles/ Python compiler Python 2.7.2 source code main():Modules/python.c  Py_Main():Modules/main.c Py_Initialize(): Python/pythonrun.c PyRun_SimpleFileExFlags PyRun_FileExFlags PyParser_ASTFromFile returns AST module Parser build CST: PyParser_ParseFileFlagsEx: Parser/parsetok.c Transform CST to AST: PyAST_FromNode(): Python/ast.c run_mod(mod)  PyAST_Compile(mod) compile AST into byte code PyEval_EvalCode runs the byte … Continue reading

Posted in python | Leave a comment