Mixing quotation marks in strings can make output larger than input · Issue #150 · dflook/python-minifier · GitHub
Skip to content

Mixing quotation marks in strings can make output larger than input #150

Description

@gabldotink

python-minifier prefers single over double quotes:

Input: print("") (9 bytes)
Output: print('') (9 bytes)

However, it switches to double quotes if there are single quotes in the string:

Input: print('\'') (11 bytes)
Output: print("'") (10 bytes)

When there are both single and double quotes in the string, it will go back to preferring single quotes:

Input: print("'\"") (12 bytes)
Output: print('\'"') (12 bytes)

However, it will still prefer single quotes even if there are more single than double quotes, so it’s possible for the output to be larger than the input:

Input: print("'\"'") (13 bytes)
Output: print('\'"\'') (14 bytes)

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions