VertexPropertyMap.fa assignment slow for filtered graphs
Assigning a value to VertexPropertyMap.fa
is significantly slower than assigning to VertexPropertyMap.a
for filtered graphs. The following example demonstrates the issue:
g = graph_tool.generation.circular_graph(500000000, 4, directed=True)
vfilt = g.new_vertex_property("bool")
vfilt.a = True
gv = graph_tool.GraphView(g, vfilt=vfilt)
dist_map = gv.new_vertex_property("int32_t")
max_val = numpy.iinfo(dist_map.a.dtype).max
print(f".fa runtime: {timeit.timeit('dist_map.fa = max_val', globals=globals(), number=1)}")
print(f".a runtime: {timeit.timeit('dist_map.a = max_val', globals=globals(), number=1)}")
On my machine (Python 3.11, MacOS Sonoma 14.5), I get the following timing results:
.fa runtime: 2.561419958001352
.a runtime: 0.033761584003514145
Per line_profiler
, >80% of the runtime of VertexPropertyMap.__get_set_f_array()
is spent on this line.