Skip to content

Set_object_enumerated doesn't store contents of generators #41905

@andrewnags

Description

@andrewnags

Steps To Reproduce

If you construct Set_object_enumerated directly with a generator, its contents won't be stored
(same with Set_object_enumerated_with_category).

sage: from sage.sets.set import Set_object_enumerated
sage: a = Set_object_enumerated(i for i in range(3))
sage: a
{0, 1, 2}
sage: a
{}

Expected Behavior

This is quite unintuitive, since it differs from the behaviour of Set and Python's set.

sage: s = Set(i for i in range(3))
sage: s
{0, 1, 2}
sage: s
{0, 1, 2}
sage: 
sage: s = set(i for i in range(3))
sage: s
{0, 1, 2}
sage: s
{0, 1, 2}

Actual Behavior

As above.

Additional Information

No response

Environment

  • OS: Linux
  • Sage Version: 10.6

Checklist

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.
  • I have read the documentation and troubleshoot guide

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions