On 10 Feb., 21:28, r0g <aioe....@technicalbloke.com> wrote: > def inet2ip(n, l=[], c=4): > if c==0: return ".".join(l) > p = 256**( c-1 ) > l.append( str(n/p) ) > return inet2ip( n-(n/p)*p, l, c-1 )
> The results for 10000 > iterations of each were as follows... > > 0.113744974136 seconds for old INET->IP method > 27.7441999912 seconds for new INET->IP method > > :-/ That's probably because your new function is broken: >>> def inet2ip(n, l=[], c=4): if c==0: return ".".join(l) p = 256**( c-1 ) l.append( str(n/p) ) return inet2ip( n-(n/p)*p, l, c-1 ) >>> inet2ip(0) '0.0.0.0' >>> inet2ip(0) '0.0.0.0.0.0.0.0' >>> inet2ip(0) '0.0.0.0.0.0.0.0.0.0.0.0' -- http://mail.python.org/mailman/listinfo/python-list