Python

共 28 篇文章。

终于抓住了py-ldap中的内存泄漏!!

• Development

之前曾经误认为 Python中存在内存泄漏,不过最终证明还是C程序的问题。Py-LDAP2这个模块在某些情况下,会泄漏一个空的List,具体泄漏代码如下:

retval = Py_BuildValue("(OOiO)", result_str, pmsg, res_msgid, pyctrls ? pyctrls : PyList_New(0));

当pyctrls == NULL时,Py_BuildValue()会为PyList_New(0)生成的那个对象再增加一个引用,这样会导致泄漏。这一问题会发生于调用result()而all=0的情形。

阅读全文… ( 本文约 196 字,阅读大致需要 1 分钟 )

漏啊,漏啊

• Development

今天给某个维护OpenLDAP相关port的老大提了几个patch,等他消息了。

另外就是Python自己也会有泄漏,而且居然是gc部分自己出了许多tuple,这年头:(

参与评论

用 iPython 做shell

• Development

学习一种语言最快的方法就是逼自己干什么事情的时候都用它——有一个利用了Python来实现的shell——iPython,可以用来代替默认的shell。

阅读全文… ( 本文约 193 字,阅读大致需要 1 分钟 )

Bug in Python re implementation?

• Development

Python includes a Regular Expression implementation, called re. However, I thought that I have hit a bug.

The following regular expression is apparantly wrong, but Python spend much CPU time to give a mismatch:

_mailcheck = re.compile("^(\w|.){3,25}$")
_mailcheck.match(“foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo”)

I think the “.” would override anything (including “\w”), but this does not happen…

参与评论

New P2P framework

• Distributed Computing

Today I have some ideas about P2P application framework. Would check if there is any available ones and whether they can fulfil my ideas. Maybe I would start a project to implement these ideas in Python and/or C++.

参与评论

How to enable Python2.4 for WinCVS?

• Development

Because sometimes I use Windows for daily desktop (the company’s IM system can’t run on FreeBSD and that’s the only reason why I can’t use FreeBSD as desktop at company) I have adopted WinCVS as development tool.

Unfortunatelly, when I have started WinCVS, it complained that it can’t find python (the version I have installed is 2.4). After searching the disk I figured out that the file exists in windows/system32/, not python24/dll. Corrected this setting and WinCVS appears to work correctly.

阅读全文… ( 本文约 98 字,阅读大致需要 1 分钟 )

关于OpenSource

• Development

很多时候我告诫自己不要去想关于OpenSource模式的问题,不过最近还是琢磨了琢磨。很久以前一个前辈跟我讨论过这个问题:

「盈利模式是一个很大的问题。现在Linux的发展模式意味着许多真正核心的开发人员并不能从中获益,这意味着一旦他们开始为生计担忧,项目很可能就会停滞不前;在国外通常会有公司雇用这些开发人员,让他们能够将项目进行下去,但在国内这种情况还非常少。」

阅读全文… ( 本文约 276 字,阅读大致需要 1 分钟 )