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

suggested improvements t- more efficient and more pythonic #7

Open
quentinjs opened this issue Mar 19, 2023 · 7 comments
Open

suggested improvements t- more efficient and more pythonic #7

quentinjs opened this issue Mar 19, 2023 · 7 comments

Comments

@quentinjs
Copy link

These 2 functions could be significantly improved.

  1. instead of returning a list with one dict entry each, just return a single dictionary with all the entries
    i used the following to quickly convert them into a proper dict
    d = {}
    for r in parsedAddress:
    key = list(r.keys())[0]
    value = list(r.values())[0]
    d[key] = value

  2. use text = re.sub('[àáâãăäāå]', '', text) it will be much faster

And where are the other functions from the library ?

def stringToJSON(string):
if not string in ['{}']:
string = string.replace('{ ', '')
string = string.replace('}', '')
string = string.replace('"', '')
string = string.split(", ")
stringList = [i.split(': ') for i in string]
outDictList = []
for i in stringList:
outDictList.append({i[0]: i[1].rstrip().lstrip()})
return outDictList
else:
return {}

def removeSpeacialChars(address):
b = {'≈': '', '≠': '', '>': '', '<': '', '+': '', '≥': '', '≤': '', '±': '', '*': '', '÷': '', '√': '',
'°': '', '⊥': '', '~': '', 'Δ': '', 'π': '', '≡': '', '≜': '', '∝': '', '∞': '', '≪': '', '≫': '',
'⌈': '', '⌉': '', '⌋': '', '⌊': '', '∑': '', '∏': '', 'γ': '', 'φ': '', '⊃': '', '⋂': '', '⋃': '',
'μ': '', 'σ': '', 'ρ': '', 'λ': '', 'χ': '', '⊄': '', '⊆': '', '⊂': '', '⊇': '', '⊅': '', '⊖': '',
'∈': '', '∉': '', '⊕': '', '⇒': '', '⇔': '', '↔': '', '∀': '', '∃': '', '∄': '', '∴': '', '∵': '',
'ε': '', '∫': '', '∮': '', '∯': '', '∰': '', 'δ': '', 'ψ': '', 'Θ': '', 'θ': '', 'α': '', 'β': '',
'ζ': '', 'η': '', 'ι': '', 'κ': '', 'ξ': '', 'τ': '', 'ω': '', '∇': ''}
for x, y in b.items():
address = address.replace(x, y)
return address

@quentinjs
Copy link
Author

Also you should dump the re-amble the exe gives and some how after a few hundred calls the buffer contains more then it should. and it starts pulling the response from the address provided a few entries go. Not sure if the exe is providing multiple answers and this is causing the problem perhaps.

@quentinjs
Copy link
Author

also when initializing, you should allow the called to set the folder where the library is kept, not use the hard coded one you used.

@selva221724
Copy link
Owner

selva221724 commented Mar 24, 2023 via email

@quentinjs
Copy link
Author

quentinjs commented Mar 25, 2023 via email

@selva221724
Copy link
Owner

selva221724 commented Mar 25, 2023 via email

@quentinjs
Copy link
Author

quentinjs commented Mar 25, 2023 via email

@quentinjs
Copy link
Author

quentinjs commented Mar 25, 2023 via email

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

No branches or pull requests

2 participants