#20201: Improving Efficiency of LinearCode.NearestNeighborDecoder method
-------------------------------------+-------------------------------------
       Reporter:  arpitdm            |        Owner:
           Type:  enhancement        |       Status:  needs_work
       Priority:  major              |    Milestone:  sage-7.2
      Component:  coding theory      |   Resolution:
       Keywords:  beginner           |    Merged in:
        Authors:  Arpit Merchant     |    Reviewers:
Report Upstream:  N/A                |  Work issues:
         Branch:                     |       Commit:
  u/arpitdm/improving_efficiency_of_linearcode_nearestneighbordecoder_method|  
170b3fc8ff8e9f7333a06e0c84f552857e911732
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by jsrn):

 > You made a mistake when declaring the iterator: `It =
 iter(self.code.list())` won't work (and does not) as `code` is a method
 over `self`. So it should be: `It = iter(self.code().list())`.

 Actually, that's bad too: `self.code().list()` is going to instantiate an
 explicit list of all codewords in memory, so you're back to using
 exponential memory. You *could* write `It = iter(self.code())`: that would
 make an explicit iterator without requiring exponential memory. However,
 that's C++ style coding. It is much more pythonic to write something like:

 {{{
 for c in self.code():
     #blah
 }}}

 It is nothing but syntactic sugar for instantiating the iterator, but it
 is much more readable and less prone to programming errors.

 I have ever only created explicit iterators in very rare cases in Python.

--
Ticket URL: <http://trac.sagemath.org/ticket/20201#comment:10>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to