def _compress(obj, comptype=None, param=None):
    'Set or check the compression of a :py:class:`pycdf.CDF` or :py:class:`pycdf.Var`\n\n    @param obj: object on which to set or check compression\n    @type obj: :py:class:`pycdf.CDF` or :py:class:`pycdf.Var`\n    @param comptype: type of compression to change to, see CDF C reference\n                     manual section 4.10. Constants for this parameter\n                     are in :py:mod:`pycdf.const`. If not specified, will not change\n                     compression.\n    @type comptype: ctypes.c_long\n    @param param: Compression parameter, see CDF CRM 4.10 and :py:mod:`pycdf.const`.\n                  If not specified, will choose reasonable default (5 for\n                  gzip; other types have only one possible parameter.)\n    @type param: ctypes.c_long\n    @return: (comptype, param) currently in effect\n    @rtype: tuple\n    '
    if isinstance(obj, CDF):
        COMPRESSION_ = const.CDF_COMPRESSION_
    elif isinstance(obj, Var):
        COMPRESSION_ = const.zVAR_COMPRESSION_
    else:
        raise ValueError('Must specify a CDF or Var type.')
    validparams = {const.NO_COMPRESSION.value: [ctypes.c_long(0)], const.RLE_COMPRESSION.value: [const.RLE_OF_ZEROs], const.HUFF_COMPRESSION.value: [const.OPTIMAL_ENCODING_TREES], const.AHUFF_COMPRESSION.value: [const.OPTIMAL_ENCODING_TREES], const.GZIP_COMPRESSION.value: [ctypes.c_long(5), ctypes.c_long(1), ctypes.c_long(2), ctypes.c_long(3), ctypes.c_long(4), ctypes.c_long(6), ctypes.c_long(7), ctypes.c_long(8), ctypes.c_long(9)]}
    comptypes = [const.NO_COMPRESSION, const.RLE_COMPRESSION, const.HUFF_COMPRESSION, const.AHUFF_COMPRESSION, const.GZIP_COMPRESSION]
    comptypevalues = [i.value for i in comptypes]
    if (comptype != None):
        if (not hasattr(comptype, 'value')):
            comptype = ctypes.c_long(comptype)
        if (param is None):
            if (not (comptype.value in validparams)):
                raise CDFError(const.BAD_COMPRESSION)
            param = validparams[comptype.value][0]
        paramlist = (ctypes.c_long * 1)(param)
        obj._call(const.PUT_, COMPRESSION_, comptype, paramlist)
    params = (ctypes.c_long * const.CDF_MAX_PARMS)(*([0] * const.CDF_MAX_PARMS))
    comptype = ctypes.c_long(0)
    percent = ctypes.c_long(0)
    obj._call(const.GET_, COMPRESSION_, ctypes.byref(comptype), ctypes.byref(params), ctypes.byref(percent))
    param = params[0]
    if (not (comptype.value in comptypevalues)):
        raise CDFError(const.BAD_COMPRESSION)
    validparamvalues = [i.value for i in validparams[comptype.value]]
    if (not (param in validparamvalues)):
        raise CDFError(const.BAD_COMPRESSION_PARM)
    comptype = comptypes[comptypevalues.index(comptype.value)]
    if (comptype in (const.RLE_COMPRESSION, const.HUFF_COMPRESSION, const.AHUFF_COMPRESSION)):
        param = validparams[comptype.value][validparamvalues.index(param)]
    return (comptype, param)
Set or check the compression of a :py:class:`pycdf.CDF` or :py:class:`pycdf.Var`

@param obj: object on which to set or check compression
@type obj: :py:class:`pycdf.CDF` or :py:class:`pycdf.Var`
@param comptype: type of compression to change to, see CDF C reference
                 manual section 4.10. Constants for this parameter
                 are in :py:mod:`pycdf.const`. If not specified, will not change
                 compression.
@type comptype: ctypes.c_long
@param param: Compression parameter, see CDF CRM 4.10 and :py:mod:`pycdf.const`.
              If not specified, will choose reasonable default (5 for
              gzip; other types have only one possible parameter.)
@type param: ctypes.c_long
@return: (comptype, param) currently in effect
@rtype: tuple
def _compress(obj, comptype=None, param=None):
    'Set or check the compression of a :py:class:`pycdf.CDF` or :py:class:`pycdf.Var`\n\n    @param obj: object on which to set or check compression\n    @type obj: :py:class:`pycdf.CDF` or :py:class:`pycdf.Var`\n    @param comptype: type of compression to change to, see CDF C reference\n                     manual section 4.10. Constants for this parameter\n                     are in :py:mod:`pycdf.const`. If not specified, will not change\n                     compression.\n    @type comptype: ctypes.c_long\n    @param param: Compression parameter, see CDF CRM 4.10 and :py:mod:`pycdf.const`.\n                  If not specified, will choose reasonable default (5 for\n                  gzip; other types have only one possible parameter.)\n    @type param: ctypes.c_long\n    @return: (comptype, param) currently in effect\n    @rtype: tuple\n    '
    if isinstance(obj, CDF):
        COMPRESSION_ = const.CDF_COMPRESSION_
    elif isinstance(obj, Var):
        COMPRESSION_ = const.zVAR_COMPRESSION_
    else:
        raise ValueError('Must specify a CDF or Var type.')
    validparams = {const.NO_COMPRESSION.value: [ctypes.c_long(0)], const.RLE_COMPRESSION.value: [const.RLE_OF_ZEROs], const.HUFF_COMPRESSION.value: [const.OPTIMAL_ENCODING_TREES], const.AHUFF_COMPRESSION.value: [const.OPTIMAL_ENCODING_TREES], const.GZIP_COMPRESSION.value: [ctypes.c_long(5), ctypes.c_long(1), ctypes.c_long(2), ctypes.c_long(3), ctypes.c_long(4), ctypes.c_long(6), ctypes.c_long(7), ctypes.c_long(8), ctypes.c_long(9)]}
    comptypes = [const.NO_COMPRESSION, const.RLE_COMPRESSION, const.HUFF_COMPRESSION, const.AHUFF_COMPRESSION, const.GZIP_COMPRESSION]
    comptypevalues = [i.value for i in comptypes]
    if (comptype != None):
        if (not hasattr(comptype, 'value')):
            comptype = ctypes.c_long(comptype)
        if (param is None):
            if (not (comptype.value in validparams)):
                raise CDFError(const.BAD_COMPRESSION)
            param = validparams[comptype.value][0]
        paramlist = (ctypes.c_long * 1)(param)
        obj._call(const.PUT_, COMPRESSION_, comptype, paramlist)
    params = (ctypes.c_long * const.CDF_MAX_PARMS)(*([0] * const.CDF_MAX_PARMS))
    comptype = ctypes.c_long(0)
    percent = ctypes.c_long(0)
    obj._call(const.GET_, COMPRESSION_, ctypes.byref(comptype), ctypes.byref(params), ctypes.byref(percent))
    param = params[0]
    if (not (comptype.value in comptypevalues)):
        raise CDFError(const.BAD_COMPRESSION)
    validparamvalues = [i.value for i in validparams[comptype.value]]
    if (not (param in validparamvalues)):
        raise CDFError(const.BAD_COMPRESSION_PARM)
    comptype = comptypes[comptypevalues.index(comptype.value)]
    if (comptype in (const.RLE_COMPRESSION, const.HUFF_COMPRESSION, const.AHUFF_COMPRESSION)):
        param = validparams[comptype.value][validparamvalues.index(param)]
    return (comptype, param)