They Called It LISP for a Reason: List Processing (2005)
Shared structure is overrated. The cases where you need a tree-like <i>mutable</i> structure are vanishingly small in modern times. Mostly it boils down to &quot;just use hash tables.&quot;<p>This isn&#x27;t just a dismissive observation. It&#x27;s the heart of why Lisp is so hard to implement. When I ignored mutable cons cells, I realized I could just implement bel in Python by using actual Python lists.<p><pre><code>    t = True
    nil = None

    def car(l):
        if l:
            return l[0]

    assert car(nil) == nil
    assert car([]) == nil
    assert car([1]) == 1
    assert car([[1]]) == [1]
    assert car(car([[1]])) == 1
    assert car(car([(1, 2)])) == 1

    def sequence(x):
        return isinstance(x, (list, tuple))

    def cdr(l):
        if l:
            if v := l[1:]:
                if v[0] == &quot;.&quot;:
                    if sequence(l):
                        if len(l) == 3 and l[1] == &quot;.&quot;:
                            return l[2]
                return v

    assert cdr(nil) == nil
    assert cdr([]) == nil
    assert cdr([1]) == nil
    assert cdr([1, &quot;.&quot;, 2]) == 2
    assert cdr((1, 2, 3)) == (2, 3)
    assert cdr(&quot;foo&quot;) == &quot;oo&quot;

    def join(x=nil, y=nil):
        if sequence(y):
            return [x, *y]
        return [x, &quot;.&quot;, y]

    assert join(nil, nil) == [nil]
    assert join(1, 2) == [1, &quot;.&quot;, 2]
    assert join(1, &#x27;&quot;foo&quot;&#x27;) == [1, &quot;.&quot;, &#x27;&quot;foo&quot;&#x27;]
</code></pre>
Presto, now you have car, cdr, and join (cons) in Python.<p>This works (and works very well). You can build lists with Lisp and then pass them off to other Python libraries -- after all, they&#x27;re just lists. And in the rare case where you care about mutating cons cells, you can just use a dict instead.<p>EDIT: See <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=33194570" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=33194570</a> for a more thorough explanation of why mutable cons cells are problematic.