reduce and metaclass for py2&3