Unnecessary import of astropy.table can slow down load of a FITS file
See original GitHub issueI am doing a little bit of io.fits benchmarking and one thing I just noticed is this import of astropy.table
can take a significant fraction of the load time of a FITS file even in cases where it isn’t needed at all.
The easiest optimisation would be to only try the table import if data is not None
but someone with a little more imagination might be able to optimise further.
My truncated pyinstrument trace:
0.488 <module> initial_benchmarks_astropy.py:1
├─ 0.207 HDUList.__getitem__ ../../../Git/astropy/astropy/io/fits/hdu/hdulist.py:304
│ └─ 0.207 HDUList._try_while_unread_hdus ../../../Git/astropy/astropy/io/fits/hdu/hdulist.py:1171
│ └─ 0.207 HDUList._read_next_hdu ../../../Git/astropy/astropy/io/fits/hdu/hdulist.py:1188
│ └─ 0.207 _BaseHDU.readfrom ../../../Git/astropy/astropy/io/fits/hdu/base.py:299
│ └─ 0.207 CompImageHDU._readfrom_internal ../../../Git/astropy/astropy/io/fits/hdu/base.py:382
│ └─ 0.206 CompImageHDU.__init__ ../../../Git/astropy/astropy/io/fits/hdu/compressed.py:403
│ └─ 0.206 CompImageHDU.__init__ ../../../Git/astropy/astropy/io/fits/hdu/table.py:851
│ └─ 0.206 <module> ../../../Git/astropy/astropy/table/__init__.py:1
Issue Analytics
- State:
- Created 10 months ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
FITS File Handling (astropy.io.fits)
Once the astropy.io.fits package is loaded using the standard convention 1, we can open an existing FITS file: >>> >>> from astropy.io import...
Read more >Fastest way to read from large FITS file? - Google Groups
Hi, I'm writing a script to convert a 1.9GB FITS file into an SQLite file. The file is a single table of ~1.8M...
Read more >astropy.io.fits FAQ
io.fits module is currently discouraged for the creation and manipulation of large tables. The FITS format itself is not designed for efficient on-disk...
Read more >2. Reading IRIS files — A low-level guide to IRIS with Python
The IRIS level 2 FITS files are the standard science data product, and can ... %matplotlib inline import numpy as np import astropy.io.fits...
Read more >Class 4 - Mark Krumholz's Web Page - Google Sites
2.1 Numpy array files; 2.2 Pickling and pickle files; 2.3 FITS image files ... Once we're done with the file, we can close...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Never put a FITS issue as “good first issue.” 😉
Let’s try with “good first issue” then 😃