yeah I am afraid I understood exactly what you meant because at first that
was my initial desire when I made Atlas.

Essentially you want auto mapping of Python objects to Pharo, so you wont
have to deal with Python and do everything from inside the Pharo image. So
essentially reading and writing Python objects as if they were Pharo
objects.

Take a more careful look to my reply, you will see that is exactly what I
am focusing on.

Unless you dont mean automatically and mean manually, which in that case is
something I have already done.

I used SmaCC , as already pointed out it already maps python syntax to
pharo objects. So lucky for you this work is done for you. But you still
need to traverse the object tree to do the remapping and there lies the
tricky part for all the reasons I already explained in the previous answer
,again assuming you want to do this automagically.

Ironically one would expect to be relative easy to convert Python objects
to Pharo objects , while making Python able to live code , incredible hard.

After trying both I can tell you that turning Python to a live coding
environment was a walk in the park. Mapping objects is making me have
nightmares.

You will be lucky if the objects are pure data of primitive format, this
means, floats, strings, integers and all the other usual suspects. In that
case you dont even need to worry about conversion you just export to JSON
and import back to Pharo and voila you have objects that are both Pharo and
Python compatible. JSON is such a common format that can be used any way
you like, you want to write it to a file, share it in memory, transmit it
through socket, anything you like its possible.

But then moment the Python objects maps to some exotic object with
dependencies  to C code, welcome to dependency hell, fasten your seat belt
its going to be a bumpy ride.

On Wed, Jan 10, 2018 at 5:59 PM Julien <julien.delplan...@inria.fr> wrote:

> Even if I learned things from your answer, I think you misunderstood what
> I was talking about. :p
>
> What I want is a mechanism to describe python’s objects from Pharo and
> being able to:
> 1. Serialise those objects from Python
> 2. Send those object to Pharo (whatever the way it is done: socket, write
> in a file from python and read from Pharo, etc…)
> 3. Materialize those serialised Python’s objects as Pharo objects.
>
> Basically, I want to be able to transfer data from Python to Pharo easily.
>
> Something better than getting the values held by Python objects by parsing
> their String representation « by hand »... :-)
>
> Julien
>
> ---
> Julien Delplanque
> Doctorant à l’Université de Lille 1
> http://juliendelplanque.be/phd.html
> Equipe Rmod, Inria
> Bâtiment B 40, avenue Halley 59650
> <https://maps.google.com/?q=40,+avenue+Halley+59650%C2%A0Villeneuve%C2%A0d'Ascq&entry=gmail&source=g>
>  Villeneuve
> <https://maps.google.com/?q=40,+avenue+Halley+59650%C2%A0Villeneuve%C2%A0d'Ascq&entry=gmail&source=g>
>  d'Ascq
> <https://maps.google.com/?q=40,+avenue+Halley+59650%C2%A0Villeneuve%C2%A0d'Ascq&entry=gmail&source=g>
> Numéro de téléphone: +333 59 35 86 40 <+33%203%2059%2035%2086%2040>
>
> Le 10 janv. 2018 à 16:43, Dimitris Chloupis <kilon.al...@gmail.com> a
> écrit :
>
>
>
> On Mon, Jan 8, 2018 at 5:50 PM Julien <julien.delplan...@inria.fr> wrote:
>
>> Beware that no mechanism to get back values from Python is defined for
>> now (except if you just want the String
>> representation of those objects, then you can get that if you use atlas).
>>
>> I’d like to have that but it is not easy. I would like a way to describe
>> how to map Python’s objects to Pharo’s objects
>> from Pharo and to have the code to do that in Python side generated
>> automatically but some thinking is needed…
>>
>> Julien
>>
>
> It won't be easy
>
> I have noted in the past the similarities between Pharo and Python but
> here there is also a massive difference.
>
> In Pharo we have the mentality of reinventing many stuffs ourselves so the
> systems is based to a very large extend on Pharo that runs on very
> efficient JIT VM. Almost everything is Pharo code.
>
> Python on the other hand is the exact opposite, Python runs on an
> extremely slow VM but more than 50% of its code in written in C, Python
> itself or its third party libraries.
>
> So the irony is that even though in theory and practice Python code is one
> of the slowest , in actual scenarios its one of the fastest able to
> outperform even Java to a very large extend because its libraries that are
> made for high performance like Numpy are predominately C code. Pretty much
> every C or C++ library has wrappers for Python which is what made it so
> popular. Hence the reason behind the insanity when it comes to top
> performance Python being second only to C++.
>
> So you will have not only map the Python oobjects  to Pharo object but
> also map the C code. Even though this may sound impossible the good news is
> that Python libraries, having the extension pyd , are basically DLLs made
> supporting a specific API which is very minimal in design. Similar to our
> UFFI , the only major difference is that library is responsible of keeping
> track of the reference count, which is used by Python GC to erase no longer
> used objects from memory. Which is a very simple increase and decrease.
>
> So not only you will have to remap the Python objects but also DLLs as
> well.
>
> To add salt to the wound , Python has something that Pharo does not.
> Multiple inheritance. Which of course makes your goal even harder. Python
> coder's generally avoid multiple inheritance as much as we avoid overriding
> doesNotUnderstand , but its a feature they use none the less.
>
> Hence why I did not even consider trying something like that. Plus you
> will be gaining no advantage because C code is unportable to Pharo anyway.
> Sure we have Slang , but Slang is extra careful with types which normal
> Pharo code does not. You will be losing performance because yes porting to
> Pharo as much as JIT VM may be great , its no much for Python libraries
> that merely leverage C. Plus you will have to update it each time the
> library changes etc.
>
> So my conclusion was that the most efficient way was to let Python execute
> the library and just manipulate Python.
>
> It's much easier to do the exact opposite, which goes against our
> mentality , and port your Pharo objects to Python objects. Because a) your
> objects will always be far less than a complete library and system b) you
> wont have to worry about C code because you wont have any c) all the other
> negatives I mention , disappear.
>
> It usual case of not being able to have your cake and eat it too.
>
>
>
>

Reply via email to