Skip to content

An alternative implementation of the Unique Representation design pattern #5120

@nthiery

Description

@nthiery

Class deriving from sage.structure.UniqueRepresentation inherit a
unique representation behavior for their instances (and consistent
default implementations of equality testing, copying, pickling, ...).

See the documentation for a brief discussion of the relative merits of
UniqueRepresentation? and UniqueFactory?.

As a prerequisite, this patch implements sage.misc.ClasscallMetaclass,
a (trivial) metaclass for customizing class calls via a static method
of the class.

This class is used extensively in upcoming sage-combinat patches:

~500 lines of doctest for 15 lines of code

CC: @sagetrac-sage-combinat

Component: misc

Keywords: unique representation

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions