def __new__(cls, name, bases, namespace, **kwargs):
    """Create a new class instance."""
    ns = dict(namespace)
    slots = ns.get('__slots__') or ()
    if not bases or bases[0] == object:
        slots = tuple(set(cls._base_slots + tuple(slots)))
    ns['__slots__'] = tuple(slots)
    new_type = type.__new__(cls, name, bases, ns)
    return new_type
