Python3 and 6model

Lucian Branescu lucian.branescu at gmail.com
Fri Apr 1 22:49:26 UTC 2011


On 1 April 2011 20:43, Lucian Branescu <lucian.branescu at gmail.com> wrote:
> In case you don't know, I'm the guy on irc that has a tendency to
> dislike things.
>
> I'm going to apply to GSoC with
> http://www.google-melange.com/gsoc/proposal/review/google/gsoc2011/lucian1900/1
>
> If it's TL;DR, I'm trying to decide between 6model or a custom object
> system. From what 6model docs I've read, I'm not convinced it can
> efficiently and easily support Python. Hence, I'm asking you fine folk
> whether 6model is appropriate.
>
> For those of you who aren't familiar with Python's object system, here
> goes a brief description: (also if you do know python and I'm
> hopelessly wrong, feel free to intervene).
>
> If you know JavaScript, Python's object system is vaguely similar.
>
> Every value in Python is an object. Objects in python have attributes.
> Similarly to JavaScript, python objects are backed by a hash (dict).
> So while in JavaScript you can either do obj.attr or obj['attr'], in
> python you can do either obj.attr or obj.__dict__['attr']. Btw, never
> write code like that in python.
>
> Methods in Python are just regular attributes that happen to be
> callable (most commonly functions). Also, these functions get "bound",
> which is fancy talk for "they get 'self' as the first argument". So in
> python obj.method(foo, bar) is equivalent to
> obj.__dict__['method'](obj, foo, bar). As an interesting consequence,
> Python can do multidispatch natively.
>
> Furthermore, functions are just objects with a __call__ method. So you
> could also instead of obj.method(foo, bar) do
> obj.__dict__['method'].__call__(obj, foo, bar). The recursiveness is
> broken with either python functions defined with 'def' (one of the
> __call__ will be a dummy for actual python bytecode) or with a C
> function in some cases.
>
> Classes are just a collection of attributes that all objects of that
> type share. Classes are also objects. However, nothings stops you from
> chanding/adding attributes (which could be functions that take self as
> a first argument) to either the class object or the instance object.
>
> What's a very hand-wavy, somewhat incomplete and slightly wrong
> description of Python's object system.
>
>
> With that in mind, do you think 6model could support python in a
> straightforward and efficient manner?
> If yes, do you think it would be a good idea to try it for GSoC? i.e.
> is 6model mature enough?

Apparently I was a bit presumptuous. Here's a link explaining it in a
bit more detail
http://www.cafepy.com/article/python_attributes_and_methods/python_attributes_and_methods.html#the-dynamic-dict


More information about the parrot-dev mailing list