Copied data shouldn't use additional memory unless the copies have been modified by writing.
( self )
| 67 | self.assertTrue( c.memoryUsage() < m + dm ) |
| 68 | |
| 69 | def testCopiedDataReferences( self ) : |
| 70 | |
| 71 | """Copied data shouldn't use additional memory unless the copies have |
| 72 | been modified by writing.""" |
| 73 | |
| 74 | c = IECore.CompoundObject() |
| 75 | d = IECore.IntVectorData( 10000 ) |
| 76 | |
| 77 | c["a"] = d |
| 78 | c["b"] = d.copy() |
| 79 | |
| 80 | c2 = IECore.CompoundObject() |
| 81 | c2["a"] = d |
| 82 | c2["b"] = d |
| 83 | self.assertTrue( abs( c.memoryUsage() - c2.memoryUsage() ) < 10 ) |
| 84 | |
| 85 | # writing to the copy should now increase the memory usage |
| 86 | m = c.memoryUsage() |
| 87 | c["b"][0] = 100 |
| 88 | self.assertTrue( c.memoryUsage()!=m ) |
| 89 | |
| 90 | if __name__ == "__main__": |
| 91 | unittest.main() |
nothing calls this directly
no test coverage detected