Stef Mientki schrieb:
hello,

I'm making a virtual machine,
in which (small) pieces of software (called bricks) are connected,
by connecting an output of a brick to the input of another brick.

A connection between 2 bricks may be of any type,
so it might be simple integer,
or a multi-nested dictionary / list or whatsoever .

Connections are made with the following statement (in simplified form)

Brick2.In = Brick2.Out

Now if the connection is a complex object, e.g. a list,
Brick2.In and Brick2.Out points to the same object,
and can automatically exchange information.

Now if the connection consists of a simple integer,
the statement Brick2.In = Brick2.Out
just assigns once a value to Brick2,
so there's no real communication anymore.
I solved that by adding modify-flags and receiver lists.

The problem is how can I determine
if a connection is a pointer or not ?
Which I'm not sure might be the same as mutable ?
( The type of connection need not be a standard Python type,
but might be any type created by the user. )

AFAIK there is no distinction possible by some attribute or function. I guess your safest bet is to provide a discreet list of immutables, and check objects for them being subclass of these. If yes, create the needed communication channels.

OTOH, the better option might even be to intercept the setting of objects on your bricks. If somebody sets a value on some brick's "slot", this is *always* something that needs to be communicated - it could be a new list, couldn't it? So knowing if that object is mutable is irrelevant I'd say.

Diez
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to