sweetpea.core.simple_sequence module

Provides a simple custom sequence type for internal use.

class sweetpea.core.simple_sequence.SimpleSequence(first_value=None, *rest_values)

Bases: MutableSequence[sweetpea.core.simple_sequence._T]

A custom generic sequence. SimpleSequence features an advanced initialization mechanism that allows for automatically converting given arguments into elements of the desired type. It can also smartly handle being given lists of elements for initialization.

The purpose of SimpleSequence was to grant classes like Clause and CNF the ability to be initialized with literals without needing to duplicate that code. SimpleSequence is a typing.MutableSequence with all the expected functionality, and it also provides built-in support for copy.copy() and copy.deepcopy().

SimpleSequence was also built to support better type-checking throughout SweetPea. To that effect, the implementation was inspired by discussion in mypy issue #4108.

insert(index, item)

Inserts the item before the given index in the sequence.

Parameters
  • index (int) –

  • item (sweetpea.core.simple_sequence._T) –

Return type

None