~~~ Python Use Question ~~~

Cameron Laird claird at lairds.com
Tue Nov 26 20:25:46 EST 2002


In article <2a001b6.0211241128.3d1ff56 at posting.google.com>,
smartcardware.com <questions at smartcardware.com> wrote:
>Thanks for everyones replies and input.  I guess what I really meant
>by not being able to embed python was the following.  Basically the
>following is the gist of my post:
>
>"I've coded apps that have used TCL, Perl, and Python as embedded
>scriptling languages. TCL was OK but provided no object oriented
>features, the Perl object model leaves much to be desired, and
>Python's internal object structure requires translating your ojects
>into python objects.
>
>My recent research shows that Javascript is by far and away the best
>option for a scripting engine. Object access is via accessor methods
>in most implementations, so you just have to add a few methods to your
>object to make them JS compatible. JS syntax is of course very much
>like Java and C++, making the language accessable to a broad range of
>programmers.
>
>Since all object access is via accessor methods, implementing
>functions usuable by the JS code doesnt introduce double translation
>issues like Python does (C++ code passes translated object to python,
>python code calls back into C++ which must instance a new object and
>translate it to be usable YUK !!
>
>JS is just passing the object around as a JSObject base class
>instance, which you can access the real type of the object, and then
>cast to your working class"
>
>As I said this was from someone else, and not my opinion or statement.
> Basically the parts of the above message I'm concerned with are as
>follows:
>
>"Python's internal object structure requires translating your ojects
>into python objects."
>
>and
>
>"double translation issues like Python does (C++ code passes
>translated object to python, python code calls back into C++ which
>must instance a new object and translate it to be usable YUK !!"
			.
			.
			.
I'm fairly confident there's at least one error here.

I'm not sure where to begin.  The "double translation"
necessary in Python is not as grave as the description
above seems to believe.  Experiment with real applica-
tions, and you'll find that, in practice, "double
translation" very, very rarely constrains performance
of applications which expose a Python extension inter-
face.

Also, Boost.Python addresses what is the real issue in
this area, I believe.

Also, JavaScript has several implementations, and I don't
believe it's accurate that they all "just pass around a
JSObject".

Also, I think there's a confusion in the above between
object as exposed datatype and object as class instance
in the sense of C++.

I also have design issues with an approach that emphasizes
user-level access to C++ instance variables.  I'm willing
to grant at least temporarily that that might be a matter
of taste.

If you want to pursue this, please start by specifying a
particular JS implementation you're considering.
-- 

Cameron Laird <Cameron at Lairds.com>
Business:  http://www.Phaseit.net
Personal:  http://phaseit.net/claird/home.html



More information about the Python-list mailing list