elist/elist.py
def uniqualize(l,**kwargs):
    '''
        from elist.elist import *
        l = [1, 2, 2]
        new = uniqualize(l)
        new
        id(l)
        id(new)
        ####
        l = [1, 2, 2]
        rslt = uniqualize(l,mode="original")
        rslt
        id(l)
        id(rslt)
    '''
    if('mode' in kwargs):
        mode = kwargs['mode']
    else:
        mode = 'new'
    pt = copy.deepcopy(l)
    seqs =[]
    freq = {}
    for i in range(0,pt.__len__()):
        v = pt[i]
        if(v in freq):
            freq[v] = freq[v] + 1
        else:
            freq[v] = 0
            seqs.append(i)
    #####下面是影响速度的关键,append特别耗时
    npt = select_seqs(pt,seqs)
    ########################
    pt = npt
    if(mode == 'new'):
        return(npt)
    else:
        l.clear()
        l.extend(npt)
        return(l)
def uniqualize(l,**kwargs):
    '''
        from elist.elist import *
        l = [1, 2, 2]
        new = uniqualize(l)
        new
        id(l)
        id(new)
        ####
        l = [1, 2, 2]
        rslt = uniqualize(l,mode="original")
        rslt
        id(l)
        id(rslt)
    '''
    if('mode' in kwargs):
        mode = kwargs['mode']
    else:
        mode = 'new'
    pt = copy.deepcopy(l)
    seqs =[]
    freq = {}
    for i in range(0,pt.__len__()):
        v = pt[i]
        if(v in freq):
            freq[v] = freq[v] + 1
        else:
            freq[v] = 0
            seqs.append(i)
    #####下面是影响速度的关键,append特别耗时
    npt = select_seqs(pt,seqs)
    ########################
    pt = npt
    if(mode == 'new'):
        return(npt)
    else:
        l.clear()
        l.extend(npt)
        return(l)
def uniqualize ( l , * * kwargs ) : if ( 'mode' in kwargs ) : mode = kwargs [ 'mode' ] else : mode = 'new' pt = copy . deepcopy ( l ) seqs = [ ] freq = { } for i in range ( 0 , pt . __len__ ( ) ) : v = pt [ i ] if ( v in freq ) : freq [ v ] = freq [ v ] + 1 else : freq [ v ] = 0 seqs . append ( i ) #####下面是影响速度的关键,append特别耗时 npt = select_seqs ( pt , seqs ) ######################## pt = npt if ( mode == 'new' ) : return ( npt ) else : l . clear ( ) l . extend ( npt ) return ( l )
from elist.elist import *
        l = [1, 2, 2]
        new = uniqualize(l)
        new
        id(l)
        id(new)
        ####
        l = [1, 2, 2]
        rslt = uniqualize(l,mode="original")
        rslt
        id(l)
        id(rslt)
from elist . elist import * l = [ 1 2 2 ] new = uniqualize ( l ) new id ( l ) id ( new ) #### l = [ 1 2 2 ] rslt = uniqualize ( l mode = original ) rslt id ( l ) id ( rslt )