# Pydsdl "maximum recursion depth exceeded" error

**URL:** <https://forum.opencyphal.org/t/pydsdl-maximum-recursion-depth-exceeded-error/1813>\
**Category:** PyCyphal\
**Created:** [January 10, 2023, 12:00am UTC](https://forum.opencyphal.org/t/pydsdl-maximum-recursion-depth-exceeded-error/1813 "2023-01-10T00:00:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mehmetkaya](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/m/eb9ed0/32.png) [@mehmetkaya](https://forum.opencyphal.org/u/mehmetkaya)\
**Post date:** [January 10, 2023, 12:00am UTC](https://forum.opencyphal.org/t/pydsdl-maximum-recursion-depth-exceeded-error/1813/1 "2023-01-10T00:00:37Z")

</div>

Hi, I have two cyphal message definitions in my cyphal\_test root namespace. In the first message, I have a single fixed size array and in the second message, I have a message1 and precisely 107 boolean fields like this:  
Message1.0.1.dsdl

```auto
uint8[8] id
@sealed

```

Message2.0.1.dsdl

```auto
Message1.0.1 m1
bool bool1
...
bool bool107

```

When I compile and read the extent field on the second message, I get the “maximum recursion depth exceeded” error when my system recursion limit is less than 970.

```auto
>>> import sys
>>> sys.setrecursionlimit(970)
>>> types = pydsdl.read_namespace('cyphal_test/')
>>> types[1].extent

```

```auto
  File "pydsdl/_bit_length_set/_symbolic.py", line 143, in max
    return sum(x.max for x in self._children)
  File "pydsdl/_bit_length_set/_symbolic.py", line 143, in <genexpr>
    return sum(x.max for x in self._children)
  File "pydsdl/_bit_length_set/_symbolic.py", line 296, in max
    self._max = self._child.max
  File "pydsdl/_bit_length_set/_symbolic.py", line 104, in max
    return self._pad(self._child.max)
  File "pydsdl/_bit_length_set/_symbolic.py", line 296, in max
    self._max = self._child.max
  File "pydsdl/_bit_length_set/_symbolic.py", line 143, in max
    return sum(x.max for x in self._children)
  File "pydsdl/_bit_length_set/_symbolic.py", line 143, in <genexpr>
    return sum(x.max for x in self._children)
  File "pydsdl/_bit_length_set/_symbolic.py", line 296, in max
    self._max = self._child.max
  File "pydsdl/_bit_length_set/_symbolic.py", line 104, in max
    return self._pad(self._child.max)
  File "pydsdl/_bit_length_set/_symbolic.py", line 296, in max
    self._max = self._child.max
  File "pydsdl/_bit_length_set/_symbolic.py", line 104, in max
    return self._pad(self._child.max)
  File "/pydsdl/_bit_length_set/_symbolic.py", line 296, in max
    self._max = self._child.max
RecursionError: maximum recursion depth exceeded

```

Is this a bug or is pydsdl truly doing so many recursive operations?

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [January 10, 2023, 1:07pm UTC](https://forum.opencyphal.org/t/pydsdl-maximum-recursion-depth-exceeded-error/1813/2 "2023-01-10T13:07:15Z")

</div>

You must be doing something exceedingly unorthodox!

> [@mehmetkaya](#):
>
> Is this a bug or is pydsdl truly doing so many recursive operations?

This is not a bug. PyDSDL uses very deep call stacks that grow linearly with the number of attributes in a data type definition. If you really must have 107 attributes in a data type definition (instead of, say, using an array like `bool[107]`), you will need to enlarge the Python stack.
