| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
cc @eendebakpt 1-2% consistenatly faster with simple replace logic, I think that it's worth to do this. PicklerMemoProxy.copy/2505entries: Mean +- std dev: [base] 136 us +- 4 us -> [opt] 133 us +- 5 us: 1.02x faster PicklerMemoProxy.copy/50005entries: Mean +- std dev: [base] 4.57 ms +- 0.06 ms -> [opt] 4.52 ms +- 0.05 ms: 1.01x faster Geometric mean: 1.02x faster import io
import pickle
import pyperf
def make_proxy(n):
buf = io.BytesIO()
pk = pickle.Pickler(buf, protocol=pickle.HIGHEST_PROTOCOL)
data = [object() for _ in range(n)]
nested = {i: [object(), object()] for i in range(n // 2)}
pk.dump(data)
pk.dump(nested)
proxy = pk.memo # PicklerMemoProxy
# Keep a reference to the source pickler alive via closure.
return pk, proxy
def main():
runner = pyperf.Runner()
for n in (1000, 20000):
pk, proxy = make_proxy(n)
entries = len(proxy.copy())
runner.bench_func(
f"PicklerMemoProxy.copy/{entries}entries",
proxy.copy,
)
if __name__ == "__main__":
main() |
Sorry, something went wrong.
|
The change itself is ok (the dict is fresh, so no risk of concurrent threads mutating). But is the proxy used in any computations? I thought the proxy was only for human inspection. |
Sorry, something went wrong.
|
Yeah, I also not sure how it will be practical |
Sorry, something went wrong.
I am fine with merging though. The code looks cleaner (although this is subjective), and if we do not merge we risk someone else making a similar PR. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.