the-algorithm icon indicating copy to clipboard operation
the-algorithm copied to clipboard

Improve python code

Open Siddhesh-Agarwal opened this issue 1 year ago • 10 comments

Here are few changes I want to implement:

  • reformat the entire Python code using isort and black.
  • add docstrings where missing
  • add type hinting using the in-built typing module
  • use faster string methods (depending on the Python version)
  • replace OrderedDict with regular dict (depending on the Python version)
  • more minor optimisations (depending on the Python version)

I can do all this but would need the following data to do that:

  • Python version being used
  • dependencies and their version

I have already started working on the first 3 and am going to complete that part. Soon, I will begin to optimise the code but would need the info to do so.

Siddhesh-Agarwal avatar Apr 11 '23 04:04 Siddhesh-Agarwal

cool

AmetuerCodr avatar Apr 11 '23 14:04 AmetuerCodr

You can't know if this works, it can't compile or test

nobodyindustries avatar Apr 11 '23 19:04 nobodyindustries

Surely any sane (or at least... well-engineered?) company like Twitter would set up unit tests?

mahmoud-moursy avatar Apr 12 '23 17:04 mahmoud-moursy

@nobodyindustries I have only done basic changes right now that would work for any python 3 code. Further optimizations depend on the python version being used by Twitter.

Also, I would suggest your read about testing.

Siddhesh-Agarwal avatar Apr 12 '23 18:04 Siddhesh-Agarwal

Hey @Siddhesh-Agarwal,

First, I'm very grateful that you did open an issue here to discuss before polluting the PR tracker like most people do.

Would it be possible to group the commits by "squashing" them?

This would make the reviewing process easier.

aloiscochard avatar Apr 13 '23 09:04 aloiscochard

@aloiscochard I seem to be having some problems with my git and am unable to merge the Commits.

Siddhesh-Agarwal avatar Apr 13 '23 13:04 Siddhesh-Agarwal

  • [x] reformat the entire Python code using isort and black.
  • [x] add docstrings where missing (done in most places)
  • [x] add type hinting using the in-built typing module (used the built-in Typing module)
  • [x] use faster string methods (depending on the Python version)
  • [x] replace OrderedDict with regular dict (depending on the Python version)
  • [x] more minor optimisations (depending on the Python version)
  • [x] fix typos

I can do some more optimizations if I was given simple information. Is Twitter using python>=3.6?

Siddhesh-Agarwal avatar Apr 13 '23 13:04 Siddhesh-Agarwal

My PR can also solve #365 and the Python part of #1451

Siddhesh-Agarwal avatar Apr 14 '23 07:04 Siddhesh-Agarwal

You can't know if this works, it can't compile or test

You're right.

jacksonchen1998 avatar Apr 20 '23 12:04 jacksonchen1998