Closed croath closed 7 months ago
The original code sample from https://github.com/ethereum/ethereum-org-website/blob/e7041d3db20c028f2bc93037eb13edb7a820396d/public/content/developers/docs/data-structures-and-encoding/patricia-merkle-trie/index.md?plain=1#L37-L48 is:
def update(node,path,value): if path == '': curnode = db.get(node) if node else [ NULL ] * 17 newnode = curnode.copy() newnode[-1] = value else: curnode = db.get(node) if node else [ NULL ] * 17 newnode = curnode.copy() newindex = update(curnode[path[0]],path[1:],value) newnode[path[0]] = newindex db.put(hash(newnode),newnode) return hash(newnode)
Shall we streamline the code a little bit with reducing the repeating part, like:
def update(node,path,value): curnode = db.get(node) if node else [ NULL ] * 17 newnode = curnode.copy() if path == '': newnode[-1] = value else: newindex = update(curnode[path[0]],path[1:],value) newnode[path[0]] = newindex db.put(hash(newnode),newnode) return hash(newnode)
Closed by #12721
The original code sample from https://github.com/ethereum/ethereum-org-website/blob/e7041d3db20c028f2bc93037eb13edb7a820396d/public/content/developers/docs/data-structures-and-encoding/patricia-merkle-trie/index.md?plain=1#L37-L48 is:
Shall we streamline the code a little bit with reducing the repeating part, like: