On 09.03.2015 12:26, François wrote:
> Thanks for these clarifications.
>
> I guess that most of the time is spent in the *copy_property* [link to git 
> <https://git.skewed.de/count0/graph-tool/blob/master/src/graph/graph_properties_copy.cc#L33>].
>  Indeed, when I provide a pre-initialized distance vector through the 
> dist_map parameter, the execution of shortest_distance is only 10ms faster.
>
> If I understood well, the *copy_property *is used to build a vector 
> initialized with one single value. If so, one would obtain the same result 
> with python and numpy with
>
> x = np.empty(array_size, dtype=float)
> x.fill(value)
>
> I did try to time this "numpy way initialization" (altough I'm not sure it 
> corresponds to *copy_property*)
>
> python -m timeit -s "import numpy as np" -n 100 "np.empty(33e6, 
> dtype=int).fill(1)"
> 100 loops, best of 3: 34.9 msec per loop
> *
> *
> These**34.9ms have to be compared to the 300ms (bake of envelope calculus) 
> that takes the *copy_property *function.
>
> Am I right about the way that the copy_property function works ? Could it be 
> improved ?

PropertyMap.copy() is slower than a simple numpy initialization because
it needs to deal with possible conversions between the values (such as
converting from string to double). However, it is possible to include a
specialization that avoids this conversion when the types are the
same. I have now included this modification in the git version, which
significantly improves the time it takes to copy a property without
conversion.

Best,
Tiago

-- 
Tiago de Paula Peixoto <[email protected]>

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
graph-tool mailing list
[email protected]
http://lists.skewed.de/mailman/listinfo/graph-tool

Reply via email to