
python
mathgl
这个作者很懒,什么都没留下…
展开
-
swig, python, g++
最近在搞GIS的东西,有些底层的库需要封装为python的extension. swig虽然古老,但是是个不错的东西, 对于c-style的library来说 很适合。 在编译为动态库前记得将后缀名改为 .pyd按照swig的文档 .so 和 .dll 均不起作用。很奇怪 使用环境:python 2.5mingw g++ ver: 3.4.5swing 1....原创 2008-07-23 23:43:24 · 204 阅读 · 0 评论 -
build psycopg2 on windows with vs
prerequisites: 1: postgresql 2: vs steps: 1: run python setup.py build build_ext --pg-config x:/pgsql/bin/pg_config.exe 2: make sure following dlls are on the path: libpq.dll...原创 2012-05-02 02:16:28 · 96 阅读 · 0 评论 -
a naive way to use dictcursor of psycopg2 with twisted adbapi
make a new file called fakedb.py and copy some contents from psycopg1.py from psycopg2 package class connection(_2connection): """psycopg 1.1.x connection.""" def cursor(self):...原创 2012-05-03 03:14:31 · 86 阅读 · 0 评论 -
change buffer size in order to send chunks data in ampoule
ampoule use name pipe to communicate among processes. There is a limit about 4096 bytes on windows. We can't send any data which has a length over 4000. hacking the twisted codes can solve this pr...原创 2011-12-03 16:08:42 · 124 阅读 · 0 评论 -
pypy的一个测试
pypy-1.9 昨天已经发布,据称性能又有所提高。 于是我特地用一个东西来测试一下: 就是bson的 encode效率 pymongo的bson自带一个用c写的扩展用于speed up速度。 在我的t400, win7下测试。大约一秒钟可以encode 10万的数据。 用pypy-1.9速度能达到多少呢? 同样的bson without c_exten...2012-06-09 16:15:28 · 197 阅读 · 0 评论 -
One way to speed up Pb invoke.
Pb (stands for Perspective broker), a built-in rpc lib of twisted has been used widely.Pb supports py built-in types directly like: int, list, dict ... complex object need extra effort to...原创 2012-03-14 21:31:17 · 106 阅读 · 0 评论 -
twisted iocp reactor is still buggy---it was fixed on 23/10/2012
I reported a bug on last weekend...This bug can be easily reproduced by sending continuous small chunks data. If we use pb or amp and send any data whose size can't fit the buffer (128K), iocp...原创 2012-03-19 14:53:44 · 146 阅读 · 0 评论 -
build psycopg2 on windows with mingw64
caution: version match problem. if the target is 32bit we need to modify cygwincompiler.py in /your_py_path/lib/disutils/cygwincompiler.py find class Mingw32CCompiler and its __init__ we ...原创 2013-01-03 20:36:23 · 109 阅读 · 0 评论 -
Determining if a point lies on the interior of a polygon
link: http://paulbourke.net/geometry/insidepoly/ here is the python code snippet: def point_inside_polygon(cls, lon,lat, coors): n = len(coors) inside = False p1x,p1...原创 2012-09-25 02:23:06 · 104 阅读 · 0 评论 -
numpy 1.7.0 fails with cx_freeze 4.3.1
It is a work around: find /numpy/core/__init__.py, and omit 'del sys' which locates at the bottom of this file. numpy 1.6.2 doesn't need 'del sys'. update: use cx_freeze 4.3.2. this prob...原创 2013-02-24 16:13:29 · 162 阅读 · 0 评论 -
build apsw manually
download sqlite sources and copy all files to apsw/src open setup.py find in finalize_options of apsw_build_ext class comment ext.libraries.append('sqlite3') find ext_modules=[Extensi...原创 2014-01-06 01:22:15 · 133 阅读 · 0 评论 -
build pyrun/python from source
quite easy on ubuntu. 1: build sqlite first.. use the latest autoconf version2: apt-get install libbz2-dev3: apt-get install zlib1g-dev4: apt-get install libssl-dev5: apt-get install lib...原创 2014-08-01 19:39:49 · 181 阅读 · 0 评论 -
static building lxml
well it is not really straightforward.. when building with static deps like python setup.py build --static_deps you may see two possible errors 1: when you saw crc iconv.xx error, you c...原创 2014-08-13 19:15:36 · 189 阅读 · 0 评论 -
compile mysqldb 1.2.3 for mysql 5.5 on windows
unlike postgres where tons of third party drivers are waiting for being chosen, for mysql, there are only a few choices and mysqldb is the best at the moment (yep, there are many pure python drivers f...原创 2011-03-29 00:09:47 · 89 阅读 · 0 评论 -
cython的另类用途
都知道py虽然方便但是却有个不是问题的问题:就是发布时的二进制格式的限制。 常用的打包有cx_freeze, py2exe等。此类工具大多将py变为pyc然后放置在.zip文档中。对于某些加密的需求可能不大合适.. 于是这时候cy就可以派上用场了。 cy的其中一个功能就是把寻常的py代码变为c wrapper py c api的形式的调用。最后变为.pyd (一个标准的.d...原创 2011-08-04 02:30:13 · 239 阅读 · 0 评论 -
我与python的故事
Python的历史大概从90年代初开始, 不过当时在中国知道这个名字的人我猜测可能很少。 而我知道这个名字的时候已经是2004年初了。当时我回国过年,年后去广州办事,偶一日因为等人无聊于是跑到天河的一间书店看书。我翻过的其中一本书是蔡学镛的<<java夜未眠>>,在比较靠后的某一章提到Python. 他的comment: 易学易用,功能强大,国外很多人使用.当时我不免觉...原创 2008-07-24 01:10:29 · 355 阅读 · 0 评论 -
python的一些推荐
看到未名的几篇帖子 使我想起了和python的一些经历,于是写了一篇咚咚。 1 书籍:python的syntax足够简单,semantics也不复杂,不怎么会使人混乱,一般来说看自带的文档足够可以学习了,看完两章便可以写出一些non-trivial的程序了。 硬要说入门书籍。 learning in python可以一看。目前的版本似乎是based on python2.3的,有些...原创 2008-08-04 16:42:47 · 141 阅读 · 0 评论 -
stackless and mathplotlib
这两个东西基本上有兼容性问题。估计和pyqt有关。2010-04-24 11:26:40 · 101 阅读 · 0 评论 -
python, network programming, windows
最近 找了一些 关于python在networking的library。从最早用的twisted,到国人写的 eurasia 3,还有别的。 总的来说,大部分在Linux下表现良好,但是在windows下表现一般,甚至有些并不支持windows。 目前windows下最高效的异步io 就是 iocp了。经过研究,发现似乎很少有第三方的语言包会直接支持这个。是不是iocp过于复杂,难...原创 2010-06-03 16:46:57 · 102 阅读 · 0 评论 -
python的third party llibs
最近应用py构建后端的整个应用层。用到不少第三方的lib。有些不怎么符合要求,于是动手改改。现在慢慢发现 改py的东西还是挺好玩的,代码大部分易读易懂,dependency也少,不用搞一大堆的包。 工作需要 以前改别人的lib很少,只有早些年改过一个 wx widgets 连接 mysql的一个macro。 之后改过 java tokyo cabinet的client...原创 2011-04-22 14:11:34 · 663 阅读 · 0 评论 -
speeding up python
python确实是十分慢的语言,有多慢?不好说,我测试过一些非io相关的程序,比java慢大约50倍是有的,比c++只会更慢(除了string操作外) 幸好python从来不缺各种工具,对于加快速度的工具选择更是丰富。数了一下有: pypy, psyco, cython,swig,pyrex等等。 这些工具的一个核心抽象说来只有一点:找出慢的部分然后把它变快。 直观的做法是把慢的部...原创 2011-06-03 15:36:00 · 173 阅读 · 0 评论 -
the simplest way to use vs 2010 with python
edit py/Lib/distutils/msvc9compiler.py find VERSION=get_build_version() replace it by VERSION=10.0原创 2011-06-03 15:48:13 · 85 阅读 · 0 评论 -
which one is thread safe?
quote: It's not so much that they're not performed, it's that because you called a reactor API from a thread, which you are never ever ever allowed to do, you have put your program into a state ...原创 2011-09-21 12:31:41 · 142 阅读 · 0 评论 -
cython的效果
我有个用py写的 crc-ccitt的验证程序(实现效率并不高) 这么个程序用cython简单转换一下。速度提高了70x ... 出于无聊,我把这段代码变为c++,用swig生成一个接口调用。 结果是:.... 这两者速度相差无几,可以忽略。。。。 再测试。。。直接拿boost的crc来用。用cython调用。 速度比py提高 大约 200x。是我自己写的校...原创 2011-06-29 00:29:46 · 127 阅读 · 0 评论 -
再谈twisted
现在我手头用的是11.0。 很好。没什么很大的问题,原来的版本对于iocp有个很奇怪的问题,现在被修复了。 今天在中文列表看了一下一堆人推荐gevent。许多人认为twisted是很twisted。文档不易懂,而且并不算太好用。 老实说twisted 的 core doc还是不错的,起码比那本 twisted programming要好。后者的例子大多都不知所云,看了更加令人崩溃。...原创 2011-06-29 17:03:40 · 131 阅读 · 0 评论 -
a tedious way to build the latest pytables
pyTables is a great product. It is extreme fast and powerful; however the current stable release lacks of index support.. fortunately, since June 2011,,(the last month...yep) the situations has...原创 2011-07-17 03:33:17 · 103 阅读 · 0 评论 -
instructions for installing some python's pkgs on ubuntu
make sure python-dev, gcc and other stuff have resided on the machine. cython.. run sudo python setup.py install is enough... cx_freeze if no ssl install libssl firstly sudo a...原创 2011-07-23 00:54:02 · 103 阅读 · 0 评论 -
python, vs 2010 & manifest problem
It looks like python community doesn't intend to "fix" this problem due to it is probably not a bug. a quick work around is open /distutils/msvc9compiler.py find def manifest_setup...原创 2013-11-02 13:33:45 · 104 阅读 · 0 评论