Loading
Showing posts with label Memo. Show all posts
Showing posts with label Memo. Show all posts

#Memo - Myself - 2009 Oct 19

Today,

1) I have Ported My Roman to Number, Python one liner to C, Speed becomes unbeatable. :-)

Python
R,r={'I':1,'V':5,'X':10,'L':50,'C':100,'D':500,'M':1000},lambda x:reduce(lambda T,x:T+R[x]-T%R[x]*2,x,0)

C
int R[]={100,500,0,0,0,0,1,0,0,50,1000,0,0,0,0,0,0,0,0,5,0,10};int r(char*s){int x=0;while(*s)x+=R[*s-'C']-x%R[*s-'C']*2,s++;return x;}

2) I Found New Python IDE, called Spyder

http://code.google.com/p/spyderlib/

# I am currently using Pyscripter and sometimes notepad++, previously I use Wing (its not free), Eric IDE, ...

3) I found Python to C++ Code Generator called shedskin, it supports limited syntax only though.

http://code.google.com/p/shedskin/

# I am sometimes using psyco, its quite good actually, psyco use JIT when It can, just skip if cannot, for shedskin, it cannot proceed at all for unsupported syntaxes. Well, It make sense though.

4) I have learn something new on new languages and new ideas, new writing styles.

http://myanmaritpros.com/forum/topics/challenge-on-programming-or

# Challenging is good, I believe :-)

Cheers,
Mark

Memo# Py_Unicode Object & wchar_t

Py_UNICODE

- Py_UNICODE is a typedef alias for either unsigned short (UCS2) or unsigned long (UCS4).
- UCS2 and UCS4 Python builds are not binary compatible.

To compile Python with UCS4,
./configure --enable-unicode=ucs4
make && make install

wchar_t

In Unix/Linux
wchar_t is unsigned long (32 bits, 4 bytes)

In Windows
wchar_t is unsigned short (16 bits, 2 bytes)

If you use wchar_t C/C++ in codes and when need to convert to Py_Unicode, your python need to be UCS4 binary.

Cheers,

Memo ; MySQL UTF8 create Database and create Table

CREATE DATABASE `dbname` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

CREATE TABLE `dbname`.`tbname` (
`itemname` TEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL
) ENGINE = MYISAM;

က်ေနာ္ဖတ္ေသာ အျခား ဘေလာ့ / ဆိုဒ္မ်ား