Closed marioroy closed 1 year ago
After testing, I settled with the following to not impact performance.
FLUSH_LIMIT: Static[int] = 65536 - 24
class My:
# In C, one can declare a static variable inside a function that
# retains its value when incremented. E.g. static int written = 0;
# In Python, one can create a class, accessed via an object var.
# But that reduces the performance by %5. I tried @classmethod,
# though not yet supported in Codon. In the end, I created this
# class to contain the few global variables. E.g. My.written += N.
buf = Array[byte](65536)
written = 0
In C, I have a fast
printint
function and wish to do the same in Codon.The following is the Codon version, but was hoping to not resort to global variables
buf
andwritten
.Is it possible to declare a var similarly in Codon, that can be updated and retain its value?