| Siyao's profile火星猫PhotosBlogLists | Help |
火星猫思遥 (注释,火星:无知) October 05 生活应该开始了今天送走了师姐。从coach station出来后,我毫无悬念地迷路了。尽管之前做足了功课,在google map上面查好了从家里到coach station的详细路线,并且截图放在ipod里面,但是,我还是迷路了。走出车站的时候,看到完全陌生的道路,而且脑子里还得多根弦,过马路的时候不能左顾右盼而是右顾左盼,于是开始感到恐慌。一恐慌,就走岔了,完全偏离方向了。于是在这个陌生的城市里面转来转去,凭着一点可怜的方向感,总算是转回了车站,然后再顺着ipod里面地图的指引,回到了家。怀念北京横平竖直的道路,几乎可以通过记忆就找到想去的地方。也许这种随性的城市规划更有魅力吧. 今天一天都是阴的,时不时下一点小雨,让人感觉心情非常的阴沉,在这个阴沉的天,送走了师姐。感谢师姐头两个星期的陪伴,没有你们我会更加的不知所措,感谢你们带我熟悉各个地方,感谢你们每天给我做饭。虽然只有两个星期,但是很怀念每天晚上和你们一起吃饭,然后一起聊天的感觉。在这陌生的地方,让我感觉到了家的温暖. 现在你们走了,我一切都要靠自己了。很佩服你们去年刚来的时候,从西斯罗出来找到coach坐两个多小时大晚上的到达Bristol,开始所有的生活,一切都是从零开始。虽然我这次来比你们幸福多了,在西斯罗T3出口就有人接,还有人开车送我到Bristol的家里,但是还是不能忘记刚开始的那种无助。你们一定比我绝望多了,所以很佩服你们。你们靠自己找到了学校,靠自己找到了超市,慢慢开始了自己的生活,而有了你们,我就便捷多了,没有付出任何努力就把所有生活需要的物资都购置齐全,不用付出任何努力就学会了所有的设施. 突然没有了依靠,什么都要靠自己的时候,又一次感觉无助,当一个人孤零零地走在刮大风还下着小雨的大街上的时候,寂寞的感觉挡都挡不住。回到家里,曾经热闹的garden floor不再热闹,失落感油然而起. 好吧,我应该开始我的新生活了,一切都靠我自己,坚强面对生活的种种困难,去熟悉这个陌生的城市,这个陌生的国家。谢谢师姐的照顾,也为你们的坚强和友谊而感动. 我要收起我的忧伤,积极乐观地面对生活. I have my precious Sunshine supporting me, I will never let you getting disappointed. October 20 爱上图书馆来北京这么久了,新生活也开始这么久了,才写第一篇,不是因为我懒,而是因为我实在没条件,之前一直在教学区上无线,教育网的条件大家也清楚了,几乎无法访问space,现在好了,在宿舍通了宽带。大运村的宽带贵不说,还限流量,共享也麻烦,还要装计费软件什么的,我可爱的ubuntu就不可能共享了。综合考虑,还是办了网通的,虽然是计时,但是有改为包月的趋势,还能用路由器共享,可以在寝室享受wifi了。
图书馆装了一个暑假的空调,终于在这个月的15号开了。除了因为北航超低的办事效率要到11月份才能将一卡通办下来所以我必须每天带着能证明我研究生身份的录取通知书才能进研究生阅览室之外,对于图书馆本身感觉还是蛮好的,因为我需要的书基本都能找到,而且没有人跟我抢原版书:) 更重要的是,还有可爱的阳光。虽然北京的阳光很少见,不是因为天不晴,而是因为环境污染太严重。我真的太喜欢这个季节的阳光了,阳光让我有寄托,有幸福的感觉。“分享阳光,分担风雨”,虽然没有人和我分担风雨,但是独享阳光的感觉还是很温馨的。 August 15 用Python给Gimp写插件原由:好不容易从emule上拖了一本“LaTeX Companion”下来,结果发现排版实在是感觉不爽。下载下来的电子档是扫描版的,但是扫描者似乎为了节省页面,将对开的两页书扫描到一个页面上,所以pdf文档的一个页面就有左右两面书,看起来很不方便,于是想办法把这些页面裁开。不知道有什么pdf工具能完成这样的任务,所以我采用的是比较麻烦的办法。 Linux下暂时没有找到提取pdf文件的工具,所以我先在虚拟机下运行Acrobat Professional,将每一个页面保存为一个jpg文件。这样,下面的任务就是将每一个文件一左一右对半裁成两个文件,一共有280多个这样的页面,几乎是不可能手工完成的,就算可以,也不愿意。原来处理数码照片的时候比较满意一个windows软件“光影魔术手”中的批处理功能,可是遗憾的是这个软件不能按照我需要的方式批量裁减这些文件,所以要另想办法。 回到Linux下,研究传说中Photoshop的替代者Gimp,具有比较合适的裁减功能,但遗憾的是不具有批处理的功能。在菜单里翻来翻去,发现一个叫python-fu的东东,貌似Gimp提供给python的接口。查了相关资料,这是Gimp提供给Python语言写插件的一个接口,功能很全面,而且非常简洁,写插件非常方便。在http://www.gimp.org/docs/python/index.html 有用Python写GImp插件的文档。用下面这些代码就完成了我的需要: #!/usr/bin/env python from gimpfu import * import os def python_batch_clip( xorg = 0, yorg = 0, width = 400, height = 300, directory = "/home", savedirectory = "/home", filename_postfix = ""): for entry in os.listdir(directory): if directory[len(directory)-1] == "/": fullpath = directory + entry else: fullpath = directory + "/" + entry if fullpath[-4:len(fullpath)] == ".jpg": # we assume this is a jpg file print "Processing file ", fullpath image = pdb.file_jpeg_load(fullpath, fullpath) pdb.gimp_image_crop(image, width, height, xorg, yorg) if savedirectory[len(savedirectory)-1] == "/": savepath = savedirectory + entry[:-4] else: savepath = savedirectory + "/" + entry[:-4] if filename_postfix != "": savepath = savepath + "_" + filename_postfix savepath = savepath + ".jpg" print "Saving file ", savepath pdb.file_jpeg_save( image, pdb.gimp_image_get_active_drawable(image), savepath, savepath, 1, 0, 1, 0, "", 0, 0, 0, 0) register( "python_fu_batch_clip", "Crop the jpg files in a directory", "Crop the jpg files in a directory", "Zheng Siyao", "Zheng Siyao", "2006", "<Toolbox>/Python-Fu/zsy/batch_clip", "RGB*, GRAY*", [ (PF_INT, "x_origin", "X origin", 0), (PF_INT, "y_origin", "Y origin", 0), (PF_INT, "width", "Width", 400), (PF_INT, "height", "Height", 300), (PF_FILE, "dir_path", "Directory", "/home"), (PF_FILE, "save_path", "Save to", "/home"), (PF_STRING, "postfix", "Filename Postfix", "") ], [], python_batch_clip) main() python_batch_clip()这个函数遍历目录下所有.jpg结尾的文件,读取每一个文件到image对象中,对每个image对象进行裁减操作,最后将image对象写入文件。 register函数有固定的格式,通过这个函数向Gimp注册插件,最后的main运行插件。Gimp启动的时候会在插件目录下寻找可用的插件,因此在使用之前必须给这个文件添加可执行属性。这个插件不是对一个文件的滤镜,属于一种工具,因此将其规为<Toolbox>类,这样,启动Gimp后,不打开任何文件,就能使用这个插件了。 运行插件的时候如下图所示,可以看出,python-fu还提供了一个输入参数的图形界面,同时,插件运行的进度也反应在这个界面上。当然,也可以用print向终端输出自己需要的信息。 August 10 闪电我比较喜欢拍照,不好意思叫摄影,因为什么也不懂,也只有一个业余的傻瓜T7,看到什么有意思的或者好看的都喜欢抓起相机就拍。前几天晚上,天空闷响,可以看到远处天边在闪,所以就拿起相机来拍了。这个T7只有2s的暴光时间,ISO也比较低,所以夜景不太好拍。我也没有三脚架,相机也不带anti-shake,所以就用最土的办法,把相机放在家里的一个台子上,对着远方,看到快要闪电了,就按下快门等待。运气还不错,守到了一个效果还不错的一闪。后来雷雨区域行进到我家头顶了,又非常走运地在头顶拍到一闪。雨越下越大,雷暴越来越强烈,不敢站在窗口了,收工。 June 22 开始暑期项目毕业论文改来改去终于改完了,迎合不同老师的胃口,做了不少修改,也浪费了不少大树。对于学校的办事规定,都要毕业了,也懒得发太多的牢骚了,反正毕业设计这事过去了就算是一个了解了。优秀也申请了,算是对得住自己一个学期来的辛勤劳动。 SoC已经开始了快一个月了,我才能有时间开始做了,刚开始就得面对Google的Mid-Term Evaluation,看样子有得熬几天才能混过这个evaluation,然后才算是正式开始这个项目。今天准备好了要看的资料,装好了要用的软件,看了看代码,算是开头了。创建了soc专用英文blog,发布了第一篇文章: http://www.planet-soc.com/blog/107 另一个深渊开始了。。。 May 25 Google Soc project accepted!两周前,一个荷兰的网友Mark邀请我参加Google Summer of Code 2006,这是从2005年开始,每年Google 公司为了促进开源事业进行的一项活动,以每个学生$4500的资金资助一些学生在夏季完成和开源有关的一个项目,今年入选的学生有600多名,涉及上百个开源社区。
我的项目属于Python Software Foundation,内容是从内存管理的角度提升一个从Python语言到C++语言的编译器的性能(Shed Skin project)。
申请项目时的Proposal如下:
Name: Zheng Siyao
Email: zhengsyao at gmail.com IM: gtalk: zhengsyao at gmail.com Abstract:
I will extend the Shed Skin compiler, so that memory management of
generated code and hence performance is improved. About Shed Skin: Shed Skin is an experimental Python-to-C++ compiler. It accepts pure,
but implicitly statically typed Python programs, and converts them into optimized equivalent C++ programs. The ultimate goal is to be able to run pure Python programs at the speed of manually written C++, so we can combine the elegance and productivity of Python with the efficiency of C++. For a set of 16 non-trivial test programs, measurements show a typical speedup of 2-40 over Psyco, about 12 on average, and 2-220 over CPython, about 45 on average [1]. Proposal: Shed Skin still misses an important type of optimization. Because the
author has mostly focused on type inference techniques, he has not paid much attention to memory management. However, Python memory management is rather inefficient: every object is allocated on the heap, causing costly (de)allocation and garbage collection overheads. Shed Skin currently does nothing to avoid such heap allocation. To improve the performance of generated C++ code, I will investigate and implement techniques to transform as much heap allocation as possible into stack- and static preallocation. This way, we can bring the performance of generated code even closer to manually written C++ code. Feasibility: It has been shown in the literature (mostly within the context of
Java) that stack- and static preallocation can significantly improve performance. The author of Shed Skin has also shown that a very simple technique to perform stack allocation improves performance by 15% on average, up to 30%, for 6 out of 16 non-trivial benchmarks. Deliverables: 1. Implement a technique to transform heap into stack allocation
2. Implement a technique to transform heap into static preallocation 3. Both techniques should work for all the benchmarks in Dufour's thesis, with performance at least matching his prototype techniques, and superior performance for more extreme demonstration programs Timeline: I'm going to work on the project for at least 12 weeks. Detailed arrangement as follows:
1. 2 weeks to get familiar with necessary theory and Shed Skin and some literature; 2. 4 weeks to implement a stack allocation technique; 3. 4 weeks to implement a static preallocation technique; 4. 2 weeks to fix any remaining problems, and to measure performance for the benchmarks in Dufour's thesis and some more extreme demonstration programs. About me: I am a Chinese undergraduate student majoring in Computer Science. I love my major and have a solid foundation in computer architecture,
programming languages, compiler principles, operating systems and so forth. I was elected to the direct PhD program of another university and will skip a Master's degree to start a PhD course in a few months. I am currently doing my undergraduate project with the topic 'Python Implemented in C++'. I have established a subset of Python with the most important features, and developed a virtual machine based on the subset, as well as a compiler that translates Python source code to bytecode. I have used C++ to implement both. During the project, I have learned a lot about Python internals including its object model, its bytecode, and its running mechanism. I like Python very much because of its compactness and elegance.
Python enables me to write beautiful code and be very productive. Although the authors of Python have put much effort into improving the performance of the Python virtual machine, as an interpreted language it is unavoidably slower than compiled languages. With the success of projects such as Shed Skin, we can fulfill our dream of having elegant code run with very high performance. 经过了两周的漫长等待,google终于在它承诺的时间,太平洋白昼时2006年5月23日的24:03分(实际上到了24号了:) ),发出了announcement。
如果你有时间,如果你有激情,如果你热爱开源,那么请关注Google Soc吧!
March 09 我是火星人研究Python的语言白皮书(其实就是Language Reference,白皮书显得很酷 |
|
||||
|
|