Skip to content

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

Closed
JMennenga wants to merge 3 commits intostandupmaths:mainfrom
JMennenga:main
Closed

Tried to compile your code using cython, didn't really work #5
JMennenga wants to merge 3 commits intostandupmaths:mainfrom
JMennenga:main

Conversation

@JMennenga
Copy link
Copy Markdown

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
Copy Markdown

Rudxain commented Oct 20, 2022

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

@ivanstepanovftw
Copy link
Copy Markdown

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