Active Topics

 


Reply
Thread Tools
epage's Avatar
Posts: 1,684 | Thanked: 1,562 times | Joined on Jun 2008 @ Austin, TX
#71
Originally Posted by caco3 View Post
Hi all

I am looking to speed up some very time consuming math functions used in python.
Basically I have to run a math function 1000 of time:
Code:
a=a+b*c
In python it takes several seconds to perform on my N900.

Now I had a look on ShedSkin as mentioned above.
(BTW: There got recently a new version released, 0.6)

I can generate a module on my Ubuntu PC and it works well (havent tested the speed). But how do I get it working on Maemo?
C usually has to be compile for a specific architecture, how is it on ShedSkin? How do I compile it for our ARM?

If I used the library compiled on the PC and import it in python on my N900, I get this error:
Code:
>>> from simple_module import func1, func2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: ./simple_module.so: cannot open shared object file: No such file or directory
Even I am in the correct directory:
Code:
> ls -l
-rw-r--r--    1 root     root         1023 Nov 17 06:45 Makefile
-rw-r--r--    1 root     root         2855 Nov 17 06:45 simple_module.cpp
-rw-r--r--    1 root     root          441 Nov 17 06:45 simple_module.hpp
-rw-r--r--    1 root     root          188 Nov 17 06:45 simple_module.py
-rwxr-xr-x    1 root     root      1491856 Nov 17 06:46 simple_module.so
I use the example from http://code.google.com/p/shedskin/do...orial-0.6.html

Or do you know a better way of speeding up basic python code?

Thank you for your help
Your PC is most likely an X86 and your device is an ARM. Code compiled for one does not work on the other. The SDK and the autobuilder let you cross compile
__________________
770, n810, n900, Ideapad S10-3t
TheOneRing, DialCentral, Gonvert, Quicknote, Multilist, ejpi, nQa, Waters of Shiloah
Programming Blog
 
caco3's Avatar
Posts: 560 | Thanked: 423 times | Joined on May 2010 @ Switzerland
#72
Thank you, this makes actually sense
I am now going to install the SDK.

Some question I have:
Is it ok to put the created library *.so into the same folder of my python application (/opt/Appname/) or should it go to /usr/libs/?
And do I also just include it into my tar.gz file I upload to maemo.org for packaging?
__________________
On N9 check out this:
CacheMe 4 the N9, a geocaching client / MiniBible, a bible viewer / TheWord brings daily bible verses onto your phone / BatteryGraph to monitor the battery drainage / doublepress2unlock to unlock your phone with a double press onto the power button / GPRS Data Usage to monitor your GPRS data usage /
and more...

On N900 check out this: SleepAnalyser to analyse your sleep movements / PasswordMaker a for a password generator
 
epage's Avatar
Posts: 1,684 | Thanked: 1,562 times | Joined on Jun 2008 @ Austin, TX
#73
Originally Posted by caco3 View Post
Thank you, this makes actually sense
I am now going to install the SDK.

Some question I have:
Is it ok to put the created library *.so into the same folder of my python application (/opt/Appname/) or should it go to /usr/libs/?
And do I also just include it into my tar.gz file I upload to maemo.org for packaging?
all of your stuff should be in your opt folder.

Ideally shedskin should be built for the packager and include only your source.

Second ideal would be to include your cpp source and have the autobuilder build your library
__________________
770, n810, n900, Ideapad S10-3t
TheOneRing, DialCentral, Gonvert, Quicknote, Multilist, ejpi, nQa, Waters of Shiloah
Programming Blog
 

The Following User Says Thank You to epage For This Useful Post:
caco3's Avatar
Posts: 560 | Thanked: 423 times | Joined on May 2010 @ Switzerland
#74
Thank you for your quick help.
I installed the SDK and could run it, also Yephyr works.
I made the hello example in http://wiki.maemo.org/Packaging and it works.
But now I do not know how I have to continue to build a c library for python instead a stand alone application.
I tried to install (compile) Shedskin, but it fails as I have not enough rights. even when I do it as fakreroot, it tells me that I have not enough rights:
Code:
[sbox-FREMANTLE_X86: ~/MyDocs/shedskin-0.6] > fakeroot
sh-2.05b# 
sh-2.05b# cd MyDocs/shedskin-0.6/
sh-2.05b# python setup.py install
/scratchbox/tools/lib/python2.3/distutils/dist.py:227: UserWarning: Unknown distribution option: 'package_data'
  warnings.warn(msg)
running install
running build
running build_py
running build_scripts
running install_lib
creating /scratchbox/tools/lib/python2.3/site-packages/shedskin
error: could not create '/scratchbox/tools/lib/python2.3/site-packages/shedskin': Permission denied

sh-2.05b# whoami
root
I guess there is also a (better) way than using shedskin, but I am confused with all the information I find in the internet.
__________________
On N9 check out this:
CacheMe 4 the N9, a geocaching client / MiniBible, a bible viewer / TheWord brings daily bible verses onto your phone / BatteryGraph to monitor the battery drainage / doublepress2unlock to unlock your phone with a double press onto the power button / GPRS Data Usage to monitor your GPRS data usage /
and more...

On N900 check out this: SleepAnalyser to analyse your sleep movements / PasswordMaker a for a password generator
 
epage's Avatar
Posts: 1,684 | Thanked: 1,562 times | Joined on Jun 2008 @ Austin, TX
#75
Originally Posted by caco3 View Post
Thank you for your quick help.
I installed the SDK and could run it, also Yephyr works.
I made the hello example in http://wiki.maemo.org/Packaging and it works.
But now I do not know how I have to continue to build a c library for python instead a stand alone application.
I tried to install (compile) Shedskin, but it fails as I have not enough rights. even when I do it as fakreroot, it tells me that I have not enough rights:
[CODE]
[sbox-FREMANTLE_X86: ~/MyDocs/shedskin-0.6] > fakeroot
sh-2.05b#
sh-2.05b# cd MyDocs/shedskin-0.6/
sh-2.05b# python setup.py install
/scratchbox/tools/lib/python2.3/distutils/dist.py:227: UserWarning: Unknown distribution option: 'package_data'
warnings.warn(msg)
running install
running build
running build_py
running build_scripts
running install_lib
creating /scratchbox/tools/lib/python2.3/site-packages/shedskin
error: could not create '/scratchbox/tools/lib/python2.3/site-packages/shedskin': Permission denied

sh-2.05b# whoami
root
[/CODE

I guess there is also a (better) way than using shedskin, but I am confused with all the information I find in the internet.
My laziness has kept me from learning to use the sdk/autobuilder for compiled apps so I won't be able to help there. The nice think about shedskin is it creates cross-platform C++ so it would be the best choice. If you can't get shedskin running on the autobuilderp, oh wel., not a big deal.

The alternative is to write in C directly and use ctypes.
__________________
770, n810, n900, Ideapad S10-3t
TheOneRing, DialCentral, Gonvert, Quicknote, Multilist, ejpi, nQa, Waters of Shiloah
Programming Blog
 
caco3's Avatar
Posts: 560 | Thanked: 423 times | Joined on May 2010 @ Switzerland
#76
Ok, I was now able to install shedskin on my SDK. I had to chmod some directories with my main root account. fakeroot in scratchbox was not able to do it.

Shedskin now got successful installed, but when I want to use it, I get this error:
Code:
sh-2.05b# shedskin test
Traceback (most recent call last):
  File "/scratchbox/tools/bin/shedskin", line 2, in ?
    import shedskin
  File "/scratchbox/tools/lib/python2.3/site-packages/shedskin/__init__.py", line 10, in ?
    import infer, cpp, annotate
  File "/scratchbox/tools/lib/python2.3/site-packages/shedskin/infer.py", line 39, in ?
    from shared import *
  File "/scratchbox/tools/lib/python2.3/site-packages/shedskin/shared.py", line 524, in ?
    errormsgs = set()
NameError: name 'set' is not defined
It seems that python2.3 is used, but it does not support the "set" command.
How do I upgrade the python version? I am a bit surprised that it is still 2.3.

@epage: Do you know how I could make a python module with c directly? I do not really care with which tools I have to do it, it just has to work.
__________________
On N9 check out this:
CacheMe 4 the N9, a geocaching client / MiniBible, a bible viewer / TheWord brings daily bible verses onto your phone / BatteryGraph to monitor the battery drainage / doublepress2unlock to unlock your phone with a double press onto the power button / GPRS Data Usage to monitor your GPRS data usage /
and more...

On N900 check out this: SleepAnalyser to analyse your sleep movements / PasswordMaker a for a password generator
 
epage's Avatar
Posts: 1,684 | Thanked: 1,562 times | Joined on Jun 2008 @ Austin, TX
#77
Originally Posted by caco3 View Post
Ok, I was now able to install shedskin on my SDK. I had to chmod some directories with my main root account. fakeroot in scratchbox was not able to do it.

Shedskin now got successful installed, but when I want to use it, I get this error:
Code:
sh-2.05b# shedskin test
Traceback (most recent call last):
  File "/scratchbox/tools/bin/shedskin", line 2, in ?
    import shedskin
  File "/scratchbox/tools/lib/python2.3/site-packages/shedskin/__init__.py", line 10, in ?
    import infer, cpp, annotate
  File "/scratchbox/tools/lib/python2.3/site-packages/shedskin/infer.py", line 39, in ?
    from shared import *
  File "/scratchbox/tools/lib/python2.3/site-packages/shedskin/shared.py", line 524, in ?
    errormsgs = set()
NameError: name 'set' is not defined
It seems that python2.3 is used, but it does not support the "set" command.
How do I upgrade the python version? I am a bit surprised that it is still 2.3.

@epage: Do you know how I could make a python module with c directly? I do not really care with which tools I have to do it, it just has to work.
The n900 should have python 2.5. As for compiled modules, Ive stayed away from them so can't help
__________________
770, n810, n900, Ideapad S10-3t
TheOneRing, DialCentral, Gonvert, Quicknote, Multilist, ejpi, nQa, Waters of Shiloah
Programming Blog
 
caco3's Avatar
Posts: 560 | Thanked: 423 times | Joined on May 2010 @ Switzerland
#78
Well, instead of loosing all my hear with getting shedskin working on a 3GB big scratchbox, would it also be possible to install gcc on the N900 itself?
Which repository would I have to add?
Which packages would I need?
Is it even possible?
According to http://maemo.org/packages/view/gcc/ there is a package for it.
__________________
On N9 check out this:
CacheMe 4 the N9, a geocaching client / MiniBible, a bible viewer / TheWord brings daily bible verses onto your phone / BatteryGraph to monitor the battery drainage / doublepress2unlock to unlock your phone with a double press onto the power button / GPRS Data Usage to monitor your GPRS data usage /
and more...

On N900 check out this: SleepAnalyser to analyse your sleep movements / PasswordMaker a for a password generator
 
caco3's Avatar
Posts: 560 | Thanked: 423 times | Joined on May 2010 @ Switzerland
#79
Allright, I am very pleased to announce that I got shedskin working on the phone.
It is slow, but it works.
For those who are interested, I made aquick how to on http://www.ruinelli.ch/how-to-get-sh...ing-on-maemo-5 .
On the quick test I did I could measure a 18x speed improvement!
__________________
On N9 check out this:
CacheMe 4 the N9, a geocaching client / MiniBible, a bible viewer / TheWord brings daily bible verses onto your phone / BatteryGraph to monitor the battery drainage / doublepress2unlock to unlock your phone with a double press onto the power button / GPRS Data Usage to monitor your GPRS data usage /
and more...

On N900 check out this: SleepAnalyser to analyse your sleep movements / PasswordMaker a for a password generator

Last edited by caco3; 2010-11-18 at 23:48.
 

The Following User Says Thank You to caco3 For This Useful Post:
caco3's Avatar
Posts: 560 | Thanked: 423 times | Joined on May 2010 @ Switzerland
#80
Umpf, now I got my module compiled with shedskin, and it works great, how ever, when I add the module (*.so) to my tar.gz and want to upload it to the autobuilder, it does not accept it
Dos anybody know how I can add a .so file to my package?
__________________
On N9 check out this:
CacheMe 4 the N9, a geocaching client / MiniBible, a bible viewer / TheWord brings daily bible verses onto your phone / BatteryGraph to monitor the battery drainage / doublepress2unlock to unlock your phone with a double press onto the power button / GPRS Data Usage to monitor your GPRS data usage /
and more...

On N900 check out this: SleepAnalyser to analyse your sleep movements / PasswordMaker a for a password generator
 
Reply

Tags
performance, python


 
Forum Jump


All times are GMT. The time now is 06:10.