question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unnecessary import of astropy.table can slow down load of a FITS file

See original GitHub issue

I 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:open
  • Created 10 months ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
pllimcommented, Nov 21, 2022

Never put a FITS issue as “good first issue.” 😉

1reaction
saimncommented, Nov 22, 2022

Let’s try with “good first issue” then 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found