Skip to content

Cythoned UniqueRepresentation #14054

@simon-king-jena

Description

@simon-king-jena

UniqueRepresentation provides a comfortable way to create unique parent structures, and automatically provides a hash and certain comparison methods.

Problems:

  • It relies on a metaclass, namely ClasscallMetaclass and thus has to be a Python class. That's bad for speed.
  • It combines two features, namely a cache and unique instance behaviour. But in many some cases we want a cache so that two distinct instances can still be equal.

Here, I suggest to

  1. separate the two features, by creating a new class sage.unique_representation.CachedRepresentation as one base of UniqueRepresentation.
  2. create a new cdef class sage.misc.fast_methods.WithRichCmpById, that provides hash and rich comparison, as expected for unique instance behaviour.

Apply

Depends on #14017
Depends on #6495
Depends on #14182
Depends on #14040
Depends on #14011

CC: @nthiery

Component: performance

Keywords: cython UniqueRepresentation

Author: Simon King

Reviewer: Travis Scrimshaw

Merged: sage-5.8.beta4

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions