Recursive Function to Produce Constrained List of Integer Partitions
Python is not designed for recursion. To avoid stack overflows there is a limit
In [2]: import sys

In [3]: sys.getrecursionlimit()
Out[3]: 1000

So we can easily design a test that will fail
In [4]: partition(1000, {1})
---------------------------------------------------------------------------
RecursionError                            Traceback (most recent call last)
&lt;ipython-input-4-884568e60acd&gt; in &lt;module&gt;()
----&gt; 1 partition(1000, {1})

&lt;ipython-input-1-60a0eb582d3c&gt; in partition(number, interesting)
      6     for x in range(1, number):
      7         if x in interesting:
----&gt; 8             for y in partition(number - x, interesting):
      9                 answer.add(tuple(sorted((x, ) + y)))
     10     return answer

... last 1 frames repeated, from the frame below ...

&lt;ipython-input-1-60a0eb582d3c&gt; in partition(number, interesting)
      6     for x in range(1, number):
      7         if x in interesting:
----&gt; 8             for y in partition(number - x, interesting):
      9                 answer.add(tuple(sorted((x, ) + y)))
     10     return answer

RecursionError: maximum recursion depth exceeded in comparison

You may increase the recursion limit
In [5]: sys.setrecursionlimit(1500)

In [6]: partition(1000, {1})
Out[6]: 
{(1, ...

but that is only applicable if your numbers are guaranteed to be in a certain range. Most probably you should implement a non-recursive solution. For 10-50 million you have to.
If your problem e. g. guarantees 1 &lt;= number &lt;= 500 you should still do some assertions in your function
assert 1 &lt;= number &lt;= 500