2008-02-04

Rolling my own simple python chart library

Two weeks ago I started looking for simple python chart library. There are interesting solutions based on cairo, GD and alike libraries. I was surprised there is no simple chart drawing library using "core" python installation environment. I found of course nice working PyCha using cairo, but there were problems on one testing servers with cairo library installation.

Portability is one of my priorities so I've been trying to find more flexible solution. So I've found SPING (Simple Platform INdependent Graphics former now as PIDDLE). It supports numerous backends like PDF, PIL, QuickDraw, PostScript, Illustrator, piddleVCR, OpenGL, Tk, wxWindows and support for others is in development. Looks promising. Ok so it gives me basic drawing capabilities. What about beatiful charts? After online research, I decided that something like PyCha would be enough. But PyCha uses cairo ... . Then idea has come- rewrite PyCha to use SPING. Idea is not so stupid- PyCha library is quite small and porting should be doable.

So I started rewriting PyCha fo SPING (codename SpingCha). The biggest part of work is porting calls typical for cairo interface to more generic SPING. I used Interface pattern with simple cairo like API. After two days I have almost working implementation, tested on original PyCha examples. By saying almost - I mean it needs better color, fonts and antialiasing handling to produce more beautiful charts.

After finishing and cleaning up code I'm planning to publish it under derived GNU Lesser General Public License. Maybe I will talk with author of PyCha to just include my ideas in main project. Meanwhile if you are interested to get SpingCha just add your comment, I will know if I need to speed up things, and release it.

UPDATE: About further story you can read new post

2008-01-28

Polyphasic sleep - sleeping less and better?

I've been planning to change my sleep schedule. The new year had come and it was good time to incorporate new habits. The first goal is to change sleep pattern to boost my creativity and make better time management through all day.

First step was to become more "early bird", it means getting up at least at 5 am. That part was easy.

So it's time for next step- polyphasic sleep. What is this all about? Instead of one big chunk of time dedicated for sleeping (usually 6-8 hours), polyphasic sleep is to take 4-6 20-30 minutes naps thorough all day.
The outcome is: summarized nap time is much shorter than usual sleeping time. And what is more controversial- you can be still rested and refreshed without health side effects. The biggest sleep time cut has Uberman's sleep schedule. One 20-30 minutes nap replaces one sleep cycle that average takes about 1.5 hour. The simplest form of polyphasic sleep is classic sleeping block plus siesta time.

I'm planning to use Everyman's sleep schedule. I have time to take 4.5 hour sleep, then one nap before leaving to work. Now it will be nice if I can afford short power nap during lunch time. And then one nap after work and dinner.

Sounds simple. I've tried to manage that schedule for few days. My first remarks:
- I didn't know that I can be so lazy to get up from bed at unusual time.
- It's hard so I have to keep more discipline.
- It's important to make most of used "sleep cycles". Keeping schedule and proper timing really makes difference.
- During adaptation I you feel sometimes like zombie at certain time of day.

Last week I caught a cold- so I held this experiment. I'm going to continue that as soon as I get better. So stay in touch and wish me luck.

2008-01-21

Looking for simple python chart library

I'm looking for simple chart library. I need it to draw stock quote and portfolio benchmarking charts.

I'm trying now pycha (python charts). It's simple but ready for most common applications. One drawback- I'm unable to setup needed cairo library on testing system, yet.

I will try to made it, but maybe there is another solution.

Do you know any python chart drawing library with less dependencies?

Update:
It is still one of the simplest and best chart utilities. I'm also using JavaScript generated charts in web browser.

2008-01-14

Mutual funds portfolio monitoring application - stage one finished

I have finished first stage of development of mutual funds portfolio monitoring application. Major bugs are fixed and all needed stats are calculated. I have been checking it on my investment account. Benchmarks don't lie- second half of 2007 was harsh for mutual fund investors :).

I'm working now on adding more visual appealing features like graphs etc. It needs also some refactoring and implementation of storing precalculated values - almost all features are data processing intensive. But more important are interesting portfolio stats, then I will work on scalability. After that I can think about first public alpha release.

I still don't have external python hosting service for development purposes, so if you know cheap one let me know.

2008-01-06

web.py update 5 - DbUtils pooling and apache MPM module

My application using web.py is still growing. One day happened something suprising. After testing on internal WSGI server, I deployed application at testing machine with Apache, and started checking. Login screen appeared and everything was looking ok. But after login I waited very long time and nothing happened. After couple of minutes (long timeout?) application finished request with exception inside DBUtils code. I've checked logs, another browser- still the same.

I googled exception code and found that it's something related with exhausted connection pool. Application grows and communication with database complicates too. I've add additional code closing connections. Still nothing.
Then I have found some interesting posts about DBUtils connection pooling method and problem related to apache MPM module.

Apache MPM modules are directly handling HTTP requests. DBUtils creates pool for application process. My default Apache configuration was MPM prefork. That means every http request is handled by one single threaded MPM process. DBUtils created pool for every apache handler process- that exhausted database connections.

There is simple solution if you use dedicated apache server- using MPM worker that works better with DBUtils multi threaded pooling.
Once again, the day was saved.