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

Tried to compile your code using cython, didn't really work #5

Closed
wants to merge 3 commits into from
Closed

Conversation

JMennenga
Copy link

Hi Matt,
I tried to compile your code using cython, it barely improved the speed.
If you want to try it you can do it using the command
python setup.py build_ext --inplace
followed by
python fiveletterwords.py

I also sped up the file loading, by using a ramdisk, that worked well.

If you didn't already know cython, it's really handy to speed up python code by compilng it to an optimized executable via C.
It needs typeannotations to really perform its magic, but when I tried to use pyannotate on your code it didn't find any types, so it couldn't do its thing. Someone with more patience could manually do the type annotations and try compiling again.
Well, it was worth a try.

Have a good day
Jannes

@Rudxain
Copy link

Rudxain commented Oct 20, 2022

#7 adds type annotations where type inference doesn't work! Are type annotations needed everywhere?

@ivanstepanovftw
Copy link

Did you try PyPy?

12974 words in total
12974 words have 5 letters
5183 words have a unique set of 5 letters
we found 2368133 combos
starting at position 0
Up to 0 after 10.320447206497192 seconds.
Up to 1000 after 401.34412360191345 seconds.
Up to 2000 after 796.3736329078674 seconds.

Extrapolated, pypy3 will take about 40 minutes on WSL2 on NTFS.

And my results for python3 on WSL2 on NTFS:

Up to 0 after 11.078052520751953 seconds.
Up to 1000 after 1143.2330737113953 seconds.

About 17 hours to complete.

@JMennenga JMennenga closed this by deleting the head repository Sep 20, 2023
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

Successfully merging this pull request may close these issues.

3 participants