2009-02-13

[Python] To raise exception doesn't take extra overhead on call

Hi, it is NISHIO Hirokazu. Today I'll write about Python tips. My friend said "Does a function which raise exceptions take extra overhead on call?" on Twitter. I don't think so, but I wrote a code:


import timeit

print timeit.Timer("foo(1)", setup="""
def foo(x):
if x:
return None
else:
return x
""").repeat()

print timeit.Timer("bar(1)", setup="""
def bar(x):
if x:
return None
else:
raise NotImplementedError
""").repeat()


The formar function doesn't raise any exceptions. The latter does. The timeit module measures time to run given code 1000000 times, and repeat it 3 times. The result is below:


[0.24111700057983398, 0.22863888740539551, 0.22955012321472168]
[0.23151803016662598, 0.23359298706054688, 0.2297508716583252]


I concluded there is no extra overhead between them.

2009-02-10

Japanese Character Problem

There are many problems to process Japanese character;"日本語".


For example, if we use MySQL with no attention, Japanese character is mistarious change.
http://d.hatena.ne.jp/showyou/20081215#1229357612

Almost case, these problems are caused by using latin as default character code.
Why don't you use unicode?


J
日本の文字を扱うとき、多くの問題がある。
例えば、何気なしにMySQLとか使うと日本の文字が化けます。

大体の答えは「デフォルトの文字コードがlatenになっていてUnicodeじゃない」からなのですが。
なんでUnicodeじゃないの?

2009-02-09

2009-02-05

Skype bot for iKnow!

We developed "Skype bot for iKnow!".

Skype bot for iKnow!

2009-02-04

The Web Server is Running - Hacker's Cafe Reinvents the Web Server







Made in Japan - Volume 30
Here's a funny little video by akio0911 of Hacker's Cafe of a laptop-endowed radio controlled car running a web server and getting directions via the internet from an iPod Touch. Does this seem a tad overly-complicated? Well, it is, but it's from a project called "Hacker's Cafe Reinvents the Web Server" which judging by the laughter at a recent presentation is most definitely is an exercise in overly-contrived hackerism delivered with a hilarious nod to Steve Jobs' keynote addresses. Just as the iPhone was supposed to combine the best of a phone, PDA, and web browser, Akio says in his presentation that this device is supposed to be the culminating combination of a remote control, a web server, and a radio-controlled truck. It's good to see people doing cool stuff and with a sense of humor.






Cyber Star Rally - AR(Augmented Reality) Game in Tokyo, Japan

Cyber Star Rally - AR(Augmented Reality) Game in Tokyo, Japan

The AR game Cyber Star Rally Challenge held on virtual Tokyo in AR World we Hacker's Cafe deployed many stars and a member was trying to collect the all stars using GPS and riding MTB!