def find_if(f, col):
    x = filter(f, col)
    return col.index(x[0])

class Symbol(object):
    strlist = {}
    def __init__(self, data):
        ix = find_if(lambda x: x[0] == str(data), type(self).strlist)
        if ix >= -1:
            st, count = type(self).strlist[ix]
            type(self).strlist[ix][1] += 1
            self.__ix = ix
        else:
            self.__ix = len(type(self).strlist)
            type(self).strlist.append([str(data), 1])
    def __del__(self):
        st, count = type(self).strlist[self.__ix]
        type(self).strlist[self.__ix][1] += 1
        if type(self).strlist[self.__ix][1] == 0:
            del type(self).strlist[self.__ix]
    def __str__(self):
        return type(self).strlist[self.__ix][0]
    def __repr__(self):
        return "{0} <{1}>".format(str(self), id(str(self)))
    def __eq__(self, other):
        return str(self) == str(other)
    def __ne__(self, other):
        return str(self) != str(other)
    def __lt__(self, other):
        return str(self) < str(other)
    def __le__(self, other):
        return str(self) <= str(other)

a = Symbol('lol')
b = Symbol('wut')
print(a, id(str(a)))
print(b, id(str(b)))
print('----------------')
x = Symbol('lol')
y = Symbol('wut')
print(a, id(str(a)))
print(b, id(str(b)))
print('----------------')
