Залагивает программа при выполнении

Программа дешифратор шифра gronsfeld - дешифрует путем подбора ключей и сравнивания варинтов с словарем на 500 к слов. Я запилил интерфейс на pySimpleGui для удобства, когда запускаю программу, ввожу шифр, запускаю дешифратор - программа работает но очень лаганно,любой клик по окну - программа не отвечает

import os
import string
import subprocess
import sys

import PySimpleGUI as sg
from numba import njit, prange
import time

string.digits + string.ascii_letters + string.punctuation + string.digits
alph = string.ascii_uppercase


def decrypt(message, key):
    return algo(message, key, -1)


def algo(text, k, op):
    k *= len(text) // len(k) + 1
    return ''.join(alph[alph.index(j) + int(k[i]) * op] for i, j in enumerate(text))


def encrypt(message, key):
    return algo(message, key, 1)


f = open('words.txt')
dictionary = f.readlines()

duplicate_wordss = []
dictionary = set(word.strip().lower() for word in dictionary)


def brute(word_decode):
    for x in prange(999999999):
        s = decrypt(word_decode.upper(), str(x))
        if s.lower() in dictionary:

            for i in duplicate_wordss:
                if i == s.lower(): break
            else:
                duplicate_wordss.append(s.lower())
                print(s + ' Key - ' + str(x))


def start(word):
    cur_time = time.time()
    brute(word)
    end_time = time.time()
    total_time = end_time - cur_time
    print('Time: ' + str(total_time))
    f.close()


def main():
    layout = [[sg.Text('Enter your text')],
              [sg.Input(key='_IN_')],  # input field where you'll type command
              [sg.Output(size=(60, 15))],  # an output area where all print output will go
              [sg.Button('Decrypt'), sg.Button('Exit')]]  # a couple of buttons

    window = sg.Window('Realtime Shell Command Output', layout)
    while True:  # Event Loop
        event, values = window.Read()
        if event in (None, 'Exit'):  # checks if user wants to
            exit
            break

        if event == 'Decrypt':  # the two lines of code needed to get button and run command
            # runCommand(cmd=values['_IN_'], window=window)
            word_decode = values['_IN_']
            start(word_decode)

    window.Close()


if __name__ == '__main__':
    main()

Ответы (0 шт):