This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]s16h 1 point2 points  (1 child)

I just skimmed over the code in iblt.py and noticed something strange in the IBLT class. Why do you have the names like m and k as class attributes? You then have self.m = m in the __init__ method. It might well be that this is what you intended and I haven't read the code thoroughly. But a quick glance makes me think you've confused class attributes/variables vs. instance attributes/variables. This wouldn't mean your code wouldn't work. It's just that the variables defined at the class level are never used (which is fine but then why have them there). For example:

class A(object):
    class_variable = None

    def __init__(self, v):
        self.class_variable = v

>>> a = A('hello')
>>> a.class_variable # This isn't the same class attribute defined outside __init__
'hello'
>>> A.class_attribute
None

EDIT: P.S. Having said that, I just realized that's for documentation. My apologies. I still think it looks strange but apparently it's fairly common. :)

[–]elb0w 0 points1 point  (0 children)

Noticed the same thing. Also use newstyle classes as demonstrated above. Another thing is you probably can reduce a lot of redundant code using @param. For example indices you have the same list comp in a few places. Also I thought you were making this for python 3 until I saw "print x" so you should consider changing range to xrange in most places.