'Create a new shared object and return its id'

def create(self, c, typeid, *args, **kwds):

    with self.mutex:
        (callable, exposed, method_to_typeid, proxytype) = self.registry[typeid]
        if (callable is None):
            assert ((len(args) == 1) and (not kwds))
            obj = args[0]
        else:
            obj = callable(*args, **kwds)
        if (exposed is None):
            exposed = public_methods(obj)
        if (method_to_typeid is not None):
            assert (type(method_to_typeid) is dict)
            exposed = (list(exposed) + list(method_to_typeid))
        ident = ('%x' % id(obj))
        util.debug('%r    callable    returned    object    with    id    %r', typeid, ident)
        self.id_to_obj[ident] = (obj, set(exposed), method_to_typeid)
        if (ident not in self.id_to_refcount):
            self.id_to_refcount[ident] = 0
    self.incref(c, ident)
    return (ident, tuple(exposed))
