victorlei / smop

Small Matlab to Python compiler
MIT License
1.08k stars 409 forks source link

Generating LALR tables takes too long #117

Closed aminazirani closed 6 years ago

aminazirani commented 6 years ago

Hello everyone,

First of all, thank you for the great repo. :) Now to my issue: When I run the generated python code, it takes nearly 2 seconds for the code to execute. This means if I create an empty .py file and just import smop, it takes nearly 2 seconds for it to execute.

#!/usr/bin/python
# Autogenerated with SMOP 
from smop.core import *

The following is what I see in terminal when executing the above code:

WARNING: Couldn't open 'parser.out'. [Errno 20] Not a directory: '/usr/local/lib/python2.7/site-packages/smop-0.0.0-py2.7.egg/smop/parser.out'
WARNING: Token 'END_UNEXPECTED' defined, but not used
WARNING: Token 'CLASSDEF' defined, but not used
WARNING: There are 2 unused tokens
Generating LALR tables
WARNING: Couldn't create 'smop.parsetab'. [Errno 20] Not a directory: '/usr/local/lib/python2.7/site-packages/smop-0.0.0-py2.7.egg/smop/parsetab.py'

Most of the spent time is after "Generating LALR tables". Where do you think the problem lies?

Thanks

victorlei commented 6 years ago

Usually only the first run after making changes takes a while. Then it caches the parse tables and the compilation is really fast. If you see that "generating lalr tables" repeatedly I want to see it. But chances are the problem already disappeared.

micklexqg commented 5 years ago

@aminakbari , Hi, i came across the same error: couldn't create '.parsetab'. [Errno 20] Not a directory... how do you solve it?

aminazirani commented 5 years ago

@aminakbari , Hi, i came across the same error: couldn't create '.parsetab'. [Errno 20] Not a directory... how do you solve it?

At that time I wasn't able to solve it but I just took another look and well, I found the solution.

Navigate to the "site-packages" folder. cd /usr/local/lib/python2.7/site-packages/ As you can see, smop is a file not a folder. A ".egg" file is a zip so just unzip it using unzip smop-0.0.0-py2.7.egg. Now rename the just created folder "smop" to "smop-0.0.0-py2.7.egg". mv smop smop-0.0.0-py2.7.egg

Now run your code again. On the first execution, it takes some time for the LALR tables to be generated but the next executions will be much faster.

micklexqg commented 5 years ago

@aminakbari , thank you, it has been ok now. but i find every generated .py files contain 'from libsmop import *', so does it have to include libsmop if I want to run the .py file?

syediu commented 5 years ago

@aminakbari I have similar issue and can't resolve. Actually i didn't find anything in python3.5 axcept dist-packages? the installation process goes smooth and i dont know where i have made mistake, Thanks