Pewarta Proxy

📋 Server Request & Proxy Logs

Loading active proxy settings...
Developed by Khairul Adha (adhexa.id)
Mengambil log server...

⚙️ Pengaturan Proxy Target

Skip to content

Decide on and document zstd options #5

Closed

Description

@emmatyping

The current module uses three IntEnums to define options for Zstandard. https://github.com/emmatyping/cpython/blob/zstd/Lib/compression/zstd/__init__.py#L184-L246

Should the API be kept as CParameter/DParameter? Should those be converted into constants on the module?

Regardless of what method is chosen, it needs to be documented.

Activity

  1. Rogdham commented on Apr 18, 2025

    @Rogdham

    I would be slightly in favor of converting into constants on the module, solely because this is what existing modules (e.g. lzma) are doing already.

  2. emmatyping commented on Apr 24, 2025

    @emmatyping
    OwnerAuthor

    One issue with using constants on a module is if someone uses compressionLevel in place of windowLogMax when passed to the decompressor, that won't be caught. They are both C enum variants with value 100. For that reason I am leaning towards keeping CParameter/DParameter.

    One possible workaround would be wrapping the constants in zstd with newtypes, i.e.

    class CParameter(int):
        """Newtype to mark a value as a compression parameter"""
    
    compressionLevel = CParameter(compressionLevel)
    ...

    Then the module state would keep the CParameter/DParameter types, and use that to check compression vs decompression parameters.

    FWIW at this point I think it would be better to keep things as they are and maybe export the CParameter attributes at the module level, e.g.

    # in compression.zstd module
    
    compressionLevel = CParameter.compressionLevel

    That makes the API simpler to use but keeps the existing known working code :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions