Saturday, April 19, 2008
Monday, April 7, 2008
用psyco优化python程序
psyco是python的一个扩展,它通过编译python代码来提升python程序的速度。
使用的方法很简单,在python程序里加上下面两句就可以了:
import psyco
psyco.full()
psyco会在程序运行时编译部分代码(具体怎么编译还不清楚),因此程序的初始化时间会增加,但运行速度会变快。
这里有一篇gentoo-wiki介绍用psyco优化portage速度的:
http://gentoo-wiki.com/TIP_Speed_up_portage_with_Psyco
这篇文章中说,用了psyco以后,portage性能可以提升2-5倍,不过同时也警告说psyco现在还不稳定,可能会带来很多问题,因此不推荐使用。
我试了一下,用了psyco的emerge速度快多了(看来2-5倍不是吹的),有一些不影响使用的小问题,比如没有用sudo的emerge会抛异常、确认删除时选“no”也会抛异常。我猜测这都是因为psyco对try-except语句支持得不好,原来的程序里catch住的异常现在引发了psyco的新异常。
不过这些问题都不影响正常使用。继续观望。
另外,有些别的python程序原生支持psyco,像Frets On Fire,我看了它的源码,它会初试使用psyco。我装了psyco以后再玩Frets On Fire,感觉快了一点,不过没有portage那么明显。
Read More
Posted by Huang Yuanhe at 7:19 AM 0 comments
Labels: Python
Friday, April 4, 2008
HOWTO XDMCP in Gnome
XDMCP stands for "X Display Manager Control Protocol" and is a network protocol. It allows a way of running X-Terminal on your PC (or Mac) and uses the X Server to provide a client/server interface between display hardware (the mouse, keyboard, and video displays) and the desktop environment while also providing both the windowing infrastructure and a standardized application interface. The X-Terminal can be displayed with an individual window or multiple windows, based on your X window system's software capabilities and setup.
On your X-Server, you must tweak the configuration of your graphical login manager (displaymanager).
for GDM, you need to change the [xdmcp]-section in your configfile:
/etc/X11/gdm/custom.conf
[xdmcp]
Enable=true
Depending on how your gdm.conf/custom.conf is set up, you might also need to add or change the [greeter] section as shown below. Without this, you will not be able to XDMCP in to your server.
[greeter]
Browser=true
How to use XDMCP
on the remote machine you can either use Xnest or simply X:
$ X -ac -query servername :1
or
$ Xnest -ac -query servername :1
where servername is your servername or IP. :1 is the display number. (:0 should be your running X-Server)
To change screen resolution of Xnest, use "geometry" option:
$ Xnest -geometry=1280x800 -ac -query servername :1
Read More
Posted by Huang Yuanhe at 10:16 PM 0 comments
Labels: Linux