Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pyodide
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
pyodide
Commits
ddd0a73b
Commit
ddd0a73b
authored
Mar 21, 2018
by
Michael Droettboom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add lazy importing for a 2x speedup importing numpy
parent
1e354c8d
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
652 additions
and
3 deletions
+652
-3
Makefile
Makefile
+12
-3
src/lazy_import.py
src/lazy_import.py
+631
-0
src/sitecustomize.py
src/sitecustomize.py
+9
-0
No files found.
Makefile
View file @
ddd0a73b
...
...
@@ -28,6 +28,7 @@ NUMPY_LIBS=\
$(NUMPY_ROOT)
/fft/fftpack_lite.so
\
$(NUMPY_ROOT)
/random/mtrand.so
SITEPACKAGES
=
root/lib/python
$(PYMINOR)
/site-packages
all
:
build/pyodide.asm.html build/pyodide.js
...
...
@@ -58,15 +59,23 @@ clean:
$(CXX)
--bind
-o
$@
$<
$(CXXFLAGS)
root/.built
:
$(CPYTHONLIB) $(NUMPY_LIBS)
root/.built
:
\
$(CPYTHONLIB)
\
$(NUMPY_LIBS)
\
src/lazy_import.py
\
src/sitecustomize.py
[
-d
root
]
&&
rm
-rf
root
mkdir
-p
root/lib
cp
-a
$(CPYTHONLIB)
/ root/lib
cp
-a
numpy/build/numpy root/lib/python
$(PYMINOR)
/site-packages
rm
-fr
root/lib/python
$(PYMINOR)
/site-packages/numpy/distutils
(
\
cd
root/lib/python
$(PYMINOR)
;
\
rm
-fr
test
distutils ensurepip idlelib __pycache__ tkinter
;
\
)
cp
-a
numpy/build/numpy
$(SITEPACKAGES)
rm
-fr
$(SITEPACKAGES)
/numpy/distutils
mkdir
$(SITEPACKAGES)
/lazy_import
cp
src/lazy_import.py
$(SITEPACKAGES)
cp
src/sitecustomize.py
$(SITEPACKAGES)
touch
root/.built
...
...
src/lazy_import.py
0 → 100644
View file @
ddd0a73b
This diff is collapsed.
Click to expand it.
src/sitecustomize.py
0 → 100644
View file @
ddd0a73b
import
lazy_import
print
(
"Setting up lazy importing..."
)
lazy_import
.
lazy_module
(
"numpy.linalg"
)
lazy_import
.
lazy_module
(
"numpy.fft"
)
lazy_import
.
lazy_module
(
"numpy.polynomial"
)
lazy_import
.
lazy_module
(
"numpy.random"
)
lazy_import
.
lazy_module
(
"numpy.ctypeslib"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment