def _pack2(obj, fp, **options):
global compatibility<EOL>ext_handlers = options.get("<STR_LIT>")<EOL>if obj is None:<EOL><INDENT>_pack_nil(obj, fp, options)<EOL><DEDENT>elif ext_handlers and obj.__class__ in ext_handlers:<EOL><INDENT>_pack_ext(ext_handlers[obj.__class__](obj), fp, options)<EOL><DEDENT>elif isinstance(obj, bool):<EOL><INDENT>_pack_boolean(obj, fp, options)<EOL><DEDENT>elif isinstance(obj, int) or isinstance(obj, long):<EOL><INDENT>_pack_integer(obj, fp, options)<EOL><DEDENT>elif isinstance(obj, float):<EOL><INDENT>_pack_float(obj, fp, options)<EOL><DEDENT>elif compatibility and isinstance(obj, unicode):<EOL><INDENT>_pack_oldspec_raw(bytes(obj), fp, options)<EOL><DEDENT>elif compatibility and isinstance(obj, bytes):<EOL><INDENT>_pack_oldspec_raw(obj, fp, options)<EOL><DEDENT>elif isinstance(obj, unicode):<EOL><INDENT>_pack_string(obj, fp, options)<EOL><DEDENT>elif isinstance(obj, str):<EOL><INDENT>_pack_binary(obj, fp, options)<EOL><DEDENT>elif isinstance(obj, list) or isinstance(obj, tuple):<EOL><INDENT>_pack_array(obj, fp, options)<EOL><DEDENT>elif isinstance(obj, dict):<EOL><INDENT>_pack_map(obj, fp, options)<EOL><DEDENT>elif isinstance(obj, datetime.datetime):<EOL><INDENT>_pack_ext_timestamp(obj, fp, options)<EOL><DEDENT>elif isinstance(obj, Ext):<EOL><INDENT>_pack_ext(obj, fp, options)<EOL><DEDENT>elif ext_handlers:<EOL><INDENT>t = next((t for t in ext_handlers.keys() if isinstance(obj, t)), None)<EOL>if t:<EOL><INDENT>_pack_ext(ext_handlers[t](obj), fp, options)<EOL><DEDENT>else:<EOL><INDENT>raise UnsupportedTypeException(<EOL>"<STR_LIT>" % str(type(obj)))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise UnsupportedTypeException("<STR_LIT>" % str(type(obj)))<EOL><DEDENT>
Serialize a Python object into MessagePack bytes.

Args:
    obj: a Python object
    fp: a .write()-supporting file-like object

Kwargs:
    ext_handlers (dict): dictionary of Ext handlers, mapping a custom type
                         to a callable that packs an instance of the type
                         into an Ext object
    force_float_precision (str): "single" to force packing floats as
                                 IEEE-754 single-precision floats,
                                 "double" to force packing floats as
                                 IEEE-754 double-precision floats.

Returns:
    None.

Raises:
    UnsupportedType(PackException):
        Object type not supported for packing.

Example:
>>> f = open('test.bin', 'wb')
>>> umsgpack.pack({u"compact": True, u"schema": 0}, f)
>>>