Skip to content

Commit

Permalink
cache some BBCode staticmethods
Browse files Browse the repository at this point in the history
  • Loading branch information
perlinm committed Jan 24, 2025
1 parent b9f274a commit 4c89c75
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions qldpc/codes/quantum.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from __future__ import annotations

import ast
import functools
import itertools
import math
import os
Expand Down Expand Up @@ -343,6 +344,7 @@ def get_node_label(self, node: Node) -> tuple[str, int, int]:
return self.get_node_label_from_orders(node, self.orders)

@staticmethod
@functools.cache
def get_node_label_from_orders(node: Node, orders: tuple[int, int]) -> tuple[str, int, int]:
"""Get the label of a qubit in a BBCode with cyclic groups of the given orders.
Expand All @@ -366,6 +368,7 @@ def get_qubit_pos(
return self.get_qubit_pos_from_orders(qubit, folded_layout, self.orders)

@staticmethod
@functools.cache
def get_qubit_pos_from_orders(
qubit: Node | tuple[str, int, int],
folded_layout: bool,
Expand Down

0 comments on commit 4c89c75

Please sign in to comment.