<s> from pypy . conftest import gettestobjspace <EOL> from pypy . objspace . std . sharingdict import SharedStructure , NUM_DIGITS <EOL> from pypy . interpreter import gateway <EOL> def instance_with_keys ( structure , * keys ) : <EOL> for key in keys : <EOL> structure = structure . get_next_structure ( key ) <EOL> return structure <EOL> def test_size_estimate ( ) : <EOL> empty_structure = SharedStructure ( ) <EOL> instances = [ ] <EOL> for i in range ( <NUM_LIT:100> ) : <EOL> instances . append ( instance_with_keys ( empty_structure , "<STR_LIT:a>" , "<STR_LIT:b>" , "<STR_LIT:c>" , "<STR_LIT:d>" , "<STR_LIT:e>" , "<STR_LIT:f>" ) ) <EOL> instances . append ( instance_with_keys ( empty_structure , "<STR_LIT:x>" , "<STR_LIT:y>" ) ) <EOL> assert empty_structure . size_estimate ( ) == <NUM_LIT:4> <EOL> assert empty_structure . other_structs . get ( "<STR_LIT:a>" ) . size_estimate ( ) == <NUM_LIT:6> <EOL> assert empty_structure . other_structs . get ( "<STR_LIT:x>" ) . size_estimate ( ) == <NUM_LIT:2> <EOL> def test_size_estimate2 ( ) : <EOL> empty_structure = SharedStructure ( ) <EOL> instances = [ ] <EOL> for i in range ( <NUM_LIT:100> ) : <EOL> instances . append ( instance_with_keys ( empty_structure , "<STR_LIT:a>" , "<STR_LIT:b>" , "<STR_LIT:c>" , "<STR_LIT:d>" , "<STR_LIT:e>" , "<STR_LIT:f>" ) ) <EOL> instances . append ( instance_with_keys ( empty_structure , "<STR_LIT:x>" , "<STR_LIT:y>" ) ) <EOL> instances . append ( instance_with_keys ( empty_structure , "<STR_LIT:x>" , "<STR_LIT:y>" ) ) <EOL> assert empty_structure . size_estimate ( ) == <NUM_LIT:3> <EOL> assert empty_structure . other_structs . get ( "<STR_LIT:a>" ) . size_estimate ( ) == <NUM_LIT:6> <EOL> assert empty_structure . other_structs . get ( "<STR_LIT:x>" ) . size_estimate ( ) == <NUM_LIT:2> </s>
