Ticket #5970: WeakReferences.patch

File WeakReferences.patch, 834 bytes (added by Simon King, 14 years ago)

Introduce Weak Reference to the cache of PolynomialRing?

  • sage/rings/polynomial/polynomial_ring_constructor.py

    # HG changeset patch
    # User Simon King <simon.king@uni-jena.de>
    # Date 1241334774 25200
    # Node ID f53f3612786ad4df71a5a4f91ae7e06a60dcf590
    # Parent  cc20d511077bc6d4c223d10f9205942be7fbd68f
    Introducing weak references in PolynomialRing constructor
    
    diff -r cc20d511077b -r f53f3612786a sage/rings/polynomial/polynomial_ring_constructor.py
    a b  
    3636from sage.rings.integer import Integer
    3737from sage.rings.integer_mod_ring import is_IntegerModRing
    3838
    39 _cache = {}
     39from weakref import WeakValueDictionary
     40_cache = WeakValueDictionary({})
    4041
    4142def PolynomialRing(base_ring, arg1=None, arg2=None,
    4243                   sparse=False, order='degrevlex',