On Monday, September 22, 2014 1:12:23 PM UTC-4, Chris Angelico wrote:
> On Tue, Sep 23, 2014 at 2:57 AM, LJ <luisjoseno...@gmail.com> wrote:
> 
> > Quick question here. In the code I am working on I am apparently doing a 
> > lot of dictionary lookups and those are taking a lot of time.
> 
> > I looked at the possibility of changing the structure and I found about the 
> > numpy structured arrays.
> 
> > The concrete question is: what would be the difference between using one or 
> > the other in terms of performance? meaning looping and performing checks an 
> > operations on them?
> 
> 
> 
> The lookups themselves almost certainly aren't actually taking the
> 
> time, unless you have some kind of crazy hash collision happening,
> 
> which is so statistically unlikely that it would have to have come
> 
> from malice. What's the code doing? What are you trying to accomplish?
> 
> It's much more likely that you have an algorithmic flaw than a data
> 
> type inefficiency.
> 
> 
> 
> ChrisA



Thank you for your reply.

Basically what is happening is the following:

I have a network in which the nodes are defined as dictionaries using the 
NetworkX package. Inside each node (each dictionary) I defined a dictionary of 
dictionaries holding attributes corresponding to different ways in which the 
node can be reached (this dictionaries I refer to as labels). 
At some point in my algorithm I am looping through some subset of nodes and 
through the labels in each node and I perform some "joining" checks with the 
labels of each node in another subset of nodes. To clarify I check for a 
feasibility condition in a pairwise manner for every label in one node and 
every label of another. This nested loop is taking time.
I wonder if the fact of defining the labels using numpy instead of dictionaries 
could imply a faster way to perform this loop.

I hope I was clear.

Thanks.

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to