On 16/09/21 2:56 pm, Mostowski Collapse wrote:
I can access the functor of a compound via:

      obj.functor

but when I flatten Compound into arrays, it would become:

      obj[0]

Should I declare a constant FUNCTOR = 0?

You could, but keep in mind that access to a global in Python
is somewhat expensive, since it requires a dictionary lookup.

There's always a tradeoff between clarity and efficiency.
In this case, I think obj[0] is clear enough -- the reader
will be well aware that the first item of a term is the
functor. Especially if you use a name that makes it clear
what kind of object it is, rather than a generic name such
as "obj".

--
Greg

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to