Ticket #13447: trac_13447-consolidated_refcount.patch

File trac_13447-consolidated_refcount.patch, 1.5 KB (added by nbruin, 7 years ago)

Consolidate two refcount systems (cruft not yet removed from patch)

  • sage/libs/singular/ring.pyx

    # HG changeset patch
    # User Nils Bruin <nbruin@sfu.ca>
    # Date 1347728520 25200
    # Node ID e44b99d9b334bb14bf4331c2d6e87652e62ea61e
    # Parent  700061226df5b343889aa4744f2376d351523dc0
    #13447: Consolidate the two refcount systems implemented for libsingular rings
    
    diff --git a/sage/libs/singular/ring.pyx b/sage/libs/singular/ring.pyx
    a b cdef ring *singular_ring_new(base_ring,  
    323323    _ring.ShortOut = 0
    324324
    325325    rChangeCurrRing(_ring)
    326    
    327     wrapped_ring = wrap_ring(_ring)
    328     if wrapped_ring in ring_refcount_dict:
    329         raise ValueError('newly created ring already in dictionary??')
    330     ring_refcount_dict[wrapped_ring] = 1
     326    _ring.ref=1
    331327    return _ring
    332328
    333329
    cdef ring *singular_ring_reference(ring  
    492488    """
    493489    if existing_ring==NULL:
    494490        raise ValueError('singular_ring_reference(ring*) called with NULL pointer.')
    495     cdef object r = wrap_ring(existing_ring)
    496     refcount = ring_refcount_dict.pop(r)
    497     ring_refcount_dict[r] = refcount+1
     491    existing_ring.ref=existing_ring.ref+1
    498492    return existing_ring
    499493
    500494
    cdef void singular_ring_delete(ring *doo 
    534528    if not ring_refcount_dict:  # arbitrary finalization order when we shut Sage down
    535529        return
    536530
    537     cdef ring_wrapper_Py r = wrap_ring(doomed)
    538     refcount = ring_refcount_dict.pop(r)
    539     if refcount > 1:
    540         ring_refcount_dict[r] = refcount-1
     531    if doomed.ref > 1:
     532        doomed.ref = doomed.ref-1
    541533        return
    542534
    543535    global currRing