Repository navigation
Commit 3af359c
committed
Cache lists of column attributes in ColDefs to avoid many calls to __getattr__
For a table with 720 columns, __getattr__ was called 722 times for 'format'
and 1441 times for 'name', which is slow. So this commit caches in the ColDefs
object these attributes, and updates the attributes when the column attributes
are changed.
Before:
❯ python -m timeit -n 5 -r 5 -s "from astropy.table import Table" "Table.read('table.fits')"
5 loops, best of 5: 1.15 sec per loop
After:
❯ python -m timeit -n 5 -r 5 -s "from astropy.table import Table" "Table.read('table.fits')"
5 loops, best of 5: 470 msec per loop1 parent 850494a commit 3af359c
1 file changed
Lines changed: 15 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1225 | 1225 | | |
1226 | 1226 | | |
1227 | 1227 | | |
| 1228 | + | |
| 1229 | + | |
1228 | 1230 | | |
1229 | 1231 | | |
1230 | 1232 | | |
| |||
1398 | 1400 | | |
1399 | 1401 | | |
1400 | 1402 | | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
1401 | 1409 | | |
1402 | 1410 | | |
1403 | 1411 | | |
| |||
1510 | 1518 | | |
1511 | 1519 | | |
1512 | 1520 | | |
| 1521 | + | |
1513 | 1522 | | |
1514 | 1523 | | |
1515 | 1524 | | |
| |||
1527 | 1536 | | |
1528 | 1537 | | |
1529 | 1538 | | |
| 1539 | + | |
1530 | 1540 | | |
1531 | 1541 | | |
1532 | 1542 | | |
| |||
1554 | 1564 | | |
1555 | 1565 | | |
1556 | 1566 | | |
| 1567 | + | |
1557 | 1568 | | |
1558 | 1569 | | |
1559 | 1570 | | |
| |||
1581 | 1592 | | |
1582 | 1593 | | |
1583 | 1594 | | |
| 1595 | + | |
1584 | 1596 | | |
1585 | 1597 | | |
1586 | 1598 | | |
| |||
1599 | 1611 | | |
1600 | 1612 | | |
1601 | 1613 | | |
| 1614 | + | |
1602 | 1615 | | |
1603 | 1616 | | |
1604 | 1617 | | |
| |||
1614 | 1627 | | |
1615 | 1628 | | |
1616 | 1629 | | |
| 1630 | + | |
1617 | 1631 | | |
1618 | 1632 | | |
1619 | 1633 | | |
| |||
1688 | 1702 | | |
1689 | 1703 | | |
1690 | 1704 | | |
1691 | | - | |
1692 | 1705 | | |
1693 | 1706 | | |
1694 | 1707 | | |
| |||
1745 | 1758 | | |
1746 | 1759 | | |
1747 | 1760 | | |
| 1761 | + | |
1748 | 1762 | | |
1749 | 1763 | | |
1750 | 1764 | | |
| |||
0 commit comments