[libre-riscv-dev] [Bug 60] N-stage 64-bit multiplier pipeline needed (signed/unsigned)

bugzilla-daemon at libre-riscv.org bugzilla-daemon at libre-riscv.org
Fri May 24 17:14:09 BST 2019


http://bugs.libre-riscv.org/show_bug.cgi?id=60

--- Comment #17 from Luke Kenneth Casson Leighton <lkcl at lkcl.net> ---
jacob, the simpler way to do what is done below is:
    def __init__(self, partition_points: PartitionPointsIn = None):
        if partition_points is None:
             partition_points = {}
        for ....

there is no need to have the entire block under a conditional "is not None".

if you absolutely must have the entire block under a conditional "is not None"
test, it is better to do this instead:

        if partition_points is None:
            return
        for .....



@@ -34,18 +38,27 @@ class PartitionPoints(Dict[int, Value]):
         * bits 10 <= ``i`` < 16
     """

-    def __init__(self, partition_points: PartitionPointsIn = {}):
+    def __init__(self, partition_points: Optional[PartitionPointsIn] = None):
+        """Create a new ``PartitionPoints``.
+
+        :param partition_points: the input partition points to values mapping.
+        """
         super().__init__()
-        for point, enabled in partition_points.items():
-            if not isinstance(point, int):
-                raise TypeError("point must be a non-negative integer")
-            if point < 0:
-                raise ValueError("point must be a non-negative integer")
-            self[point] = Value.wrap(enabled)
+        if partition_points is not None:
+            for point, enabled in partition_points.items():
+                if not isinstance(point, int):
+                    raise TypeError("point must be a non-negative integer")
+                if point < 0:
+                    raise ValueError("point must be a non-negative integer")
+                self[point] = Value.wrap(enabled)

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the libre-riscv-dev mailing list