Fastpath for iset when we are only setting a single position and the Block currently in that position is itself single-column. In this case we can swap out the entire Block and blklocs and blknos are unaffected.
(
self,
loc: int,
value: ArrayLike,
inplace: bool,
blkno: int,
blk: Block,
refs: BlockValuesRefs | None = None,
)
| 1480 | self._blknos[nb.mgr_locs.indexer] = i + nr_blocks |
| 1481 | |
| 1482 | def _iset_single( |
| 1483 | self, |
| 1484 | loc: int, |
| 1485 | value: ArrayLike, |
| 1486 | inplace: bool, |
| 1487 | blkno: int, |
| 1488 | blk: Block, |
| 1489 | refs: BlockValuesRefs | None = None, |
| 1490 | ) -> None: |
| 1491 | """ |
| 1492 | Fastpath for iset when we are only setting a single position and |
| 1493 | the Block currently in that position is itself single-column. |
| 1494 | |
| 1495 | In this case we can swap out the entire Block and blklocs and blknos |
| 1496 | are unaffected. |
| 1497 | """ |
| 1498 | # Caller is responsible for verifying value.shape |
| 1499 | |
| 1500 | if inplace and blk.should_store(value): |
| 1501 | copy = not self._has_no_reference_block(blkno) |
| 1502 | iloc = self.blklocs[loc] |
| 1503 | blk.set_inplace(slice(iloc, iloc + 1), value, copy=copy) |
| 1504 | return |
| 1505 | |
| 1506 | nb = new_block_2d(value, placement=blk._mgr_locs, refs=refs) |
| 1507 | old_blocks = self.blocks |
| 1508 | new_blocks = (*old_blocks[:blkno], nb, *old_blocks[blkno + 1 :]) |
| 1509 | self.blocks = new_blocks |
| 1510 | return |
| 1511 | |
| 1512 | def column_setitem( |
| 1513 | self, loc: int, idx: int | slice | np.ndarray, value, inplace_only: bool = False |
no test coverage detected