[Bf-committers] Python Access to some properties of nodes

Dan Eicher dan at trollwerks.org
Sun Dec 23 03:28:11 CET 2012


On Sat, Dec 22, 2012 at 12:21 AM, Lukas Tönne <lukas.toenne at gmail.com>wrote:

> IMHO storing the links in a separate list like we do now is one of the
> more well-designed code parts ;)
>
> It may be slightly inconvenient if you want to get a list of links for
> a specific socket, but it has several advantages over storing lists of
> links in each socket or node:
>
> * If each socket stores its own link list that means a lot more
> overhead for all those lists. Now we have exactly 1 list.
> * You only ever need a single loop. If each socket has a list of
> links, to walk over all links in a node tree (e.g. for drawing or the
> cut operator) you need to walk over all nodes and then all sockets and
> then all links ...
> * Storing a link in sockets is ambiguous, you could store the link
> either in the output or input socket. If you store it on one side only
> you have to loop over everything again to find links of the other
> side. If you store it in both you have to keep them in sync, which is
> error prone and leads to redundant data.
> * In terms of time complexity having to filter the list of all links
> vs. a reduced list of socket links does not make much difference, both
> are essentially O(N+M), where N is number of nodes, M is number of
> links. In general though the node DNA should not be judged by
> performance criteria too much, if you need to access the node
> structure millions of times (e.g. in rendering) you should create an
> optimized structure with arrays instead of linked lists and can store
> links in whatever way is needed for fast access. All modern node
> systems in Blender (cycles, compositor) do this.
>
> Bottom line: the single links list is the best all-round solution for
> the purpose of storing data in .blend files and user manipulation.
>

I was really only talking about how it's exposed to python, not rewriting
the way nodes work internally.

Script writers shouldn't need to know (or care) how things work inside
blender, they just need a quick and easy way to figure out which socket
links to which other socket(s) and having to iterate over a list of links
and compare with the socket they're trying to find isn't really 'quick and
easy'.

Basically all I'm saying is move the links from a property of the Node to
the NodeSocket where it should really be.

Dan


More information about the Bf-committers mailing list