Re: Should I use "if" or "try" (as a matter of speed)?
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > My shot would be to test it like this on your platform like this: > > #!/usr/bin/env python > import datetime, time > t1 = datetime.datetime.now() > for i in [str(x) for x in range(100)]: > if int(i) == i: > i + 1 > t2 = datetime.datetime.now() > print t2 - t1 > for i in [str(x) for x in range(100)]: > try: > int(i) +1 > except: > pass > t3 = datetime.datetime.now() > print t3 - t2 > > for me (on python 2.4.1 on Linux on a AMD Sempron 2200+) it gives: > 0:00:00.000637 > 0:00:00.000823 PowerBook:~/Desktop wezzy$ python test.py 0:00:00.001206 0:00:00.002092 Python 2.4.1 Pb15 with Tiger -- Ciao Fabio -- http://mail.python.org/mailman/listinfo/python-list
Modify a C++ instance from the embed python interpreter
Hi, is there a tool that automatically expose an object to python? i have an instance of a C++ (or ObjC) object and i want to pass it to the embed interpreter that runs inside my program. Python code have to call c++ method and register some callback. I know that swig helps when python creates c++ instance but i've the instance and i want to use it with python. Thanks -- Ciao Fabio -- http://mail.python.org/mailman/listinfo/python-list
Re: Modify a C++ instance from the embed python interpreter
Diez B. Roggisch <[EMAIL PROTECTED]> wrote:
> Wezzy wrote:
> > Hi, is there a tool that automatically expose an object to python? i
> > have an instance of a C++ (or ObjC) object and i want to pass it to the
> > embed interpreter that runs inside my program.
> > Python code have to call c++ method and register some callback.
> >
> > I know that swig helps when python creates c++ instance but i've the
> > instance and i want to use it with python.
>
> That is the same case, wrt SWIG - the objects methods get accessed by
> functions like
>
> int Object_foo(Object *s) {
> return s->foo();
> }
Can you post few line of code ?
> So passing a exiting object reference to such a function will work. You
> might also consider using SIP, it appears to me to be much more OO.
>
> Diez
well i'll look to SIP but i prefer to use swig because it can interface
C++ with other language such as ruby
--
Ciao
Fabio
--
http://mail.python.org/mailman/listinfo/python-list
