MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / init_objects

Method init_objects

test/perf/compiled_extensions/row.py:89–148  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

87 }
88
89 def init_objects(self):
90 from sqlalchemy.engine.result import SimpleResultMetaData
91 from string import ascii_letters
92
93 self.parent = SimpleResultMetaData(("a", "b", "c"))
94 self.row_args = (
95 self.parent,
96 self.parent._processors,
97 self.parent._key_to_index,
98 (1, 2, 3),
99 )
100 self.parent_long = SimpleResultMetaData(tuple(ascii_letters))
101 self.row_long_args = (
102 self.parent_long,
103 self.parent_long._processors,
104 self.parent_long._key_to_index,
105 tuple(range(len(ascii_letters))),
106 )
107 self.row = self.impl(*self.row_args)
108 self.row_long = self.impl(*self.row_long_args)
109 assert isinstance(self.row, self.impl), type(self.row)
110
111 class Row(self.impl):
112 pass
113
114 class RowMap(self.impl):
115 __getitem__ = self.impl._get_by_key_impl_mapping
116
117 self.Row = Row
118 self.row_map = RowMap(*self.row_args)
119 self.row_long_map = RowMap(*self.row_long_args)
120
121 self.row_state = self.row.__getstate__()
122 self.row_long_state = self.row_long.__getstate__()
123
124 assert len(ascii_letters) == 52
125 _proc = [None, int, float, None, str] * 10
126 _proc += [int, float]
127 self.parent_proc = SimpleResultMetaData(
128 tuple(ascii_letters),
129 _processors=_proc,
130 )
131 self.row_proc_args = (
132 self.parent_proc,
133 self.parent_proc._processors,
134 self.parent_proc._key_to_index,
135 tuple(range(len(ascii_letters))),
136 )
137
138 self.parent_proc_none = SimpleResultMetaData(
139 tuple(ascii_letters), _processors=[None] * 52
140 )
141 self.row_proc_none_args = (
142 self.parent_proc_none,
143 # NOTE: usually the code calls _effective_processors that returns
144 # None for this case of all None.
145 self.parent_proc_none._processors,
146 self.parent_proc_none._key_to_index,

Callers 3

get_by_key_recreateMethod · 0.95
get_by_key_recreate2Method · 0.95
getattr_recreateMethod · 0.95

Calls 3

RowMapClass · 0.85
__getstate__Method · 0.45

Tested by

no test coverage detected