Skip to content

Pickling support for finite word defined by callable and iterable #7619

@seblabbe

Description

@seblabbe

Currently pickling doesn't work for finite word defined by iterator and callable :

sage: w = Word(iter('abcdefghijkl'))
sage: loads(dumps(w))
Traceback (most recent call last):
...
PicklingError: Can't pickle <type 'generator'>: attribute lookup __builtin__.generator failed

This is not too hard to support. One just have to expand the iterator to a list (or a tuple?) and save the list instead:

sage: w = Word(iter('abcdefghijkl'))
sage: loads(dumps(w))
word: abcdefghijkl
sage: type(_)
<class 'sage.combinat.words.word.FiniteWord_list'>

This is more general solution to the problem solved in #7519.

CC: @saliola

Component: combinatorics

Keywords: words

Author: Sébastien Labbé

Reviewer: Franco Saliola

Merged: sage-4.3.4.alpha0

Issue created by migration from https://trac.sagemath.org/ticket/7619

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions