Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion #25

Open
tthn0 opened this issue Apr 18, 2021 · 3 comments
Open

Suggestion #25

tthn0 opened this issue Apr 18, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@tthn0
Copy link

tthn0 commented Apr 18, 2021

This:

from pymongo import MongoClient

connection_str = 'connection_str'

cluster = MongoClient(connection_str)

database = cluster['db']

collection = database['col']

document = collection.find()

if document['_id'] == 123:
    print('ok')

By default turns into:

from pymongo import MongoClient as A
B='connection_str'
C=A(B)
D=C['db']
E=D['col']
F=E.find()
if F['_id']==123:print('ok')

But it could easily be more compact to save a few more bytes like so:

from pymongo import MongoClient as A
if A('connection_str')['db']['col'].find()['_id']==123:print('ok')

Also, please make an option to turn into a one-liner for all possible statements! (Separated by semicolons)

Edit to make my previous sentence clearer: although the output size wouldn't change, please add a "one-liner" option to separate statements by semicolons instead of newlines where possible

@dflook
Copy link
Owner

dflook commented Apr 18, 2021

These are both good ideas!

Currently python-minifier prefers to use newlines where possible instead of semicolons for readability, but I can see how a one-liner would be more useful.

@dflook dflook added the enhancement New feature or request label Apr 18, 2021
@amaank404
Copy link

how about adding semicolons for the obfuscation, makes it harder for reverse engineering. this reduces the space further in indented blocks because semicolons reduce the requirement to indent in certain locations.

@amaank404 amaank404 mentioned this issue Apr 22, 2021
@dflook
Copy link
Owner

dflook commented Apr 22, 2021

@xcodz-dot Semicolons are already used in indented blocks. Newlines would only be used at the module level, where it makes no difference to the output size.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants