0xPolygonZero / plonky2

Apache License 2.0
745 stars 270 forks source link

fix: remove trivial allocations and `try_into` #1573

Open Daniel-Aaron-Bloom opened 2 months ago

Daniel-Aaron-Bloom commented 2 months ago

Use the following array tools to avoid allocations and try_into calls:

Some of the try_into calls are more of a nit just because they look like allocations but are really just slice conversions, but it was easier to just get rid of all of them.

Daniel-Aaron-Bloom commented 2 months ago

Fair.

I would note though that specialization is probably the least likely feature to be stabilized in the near future, so depending on your plans to remove that from plonky2_field, the introduction of these features may or may not lengthen the timeline to stability (assuming that's your goal).

Other than micro-benchmarks, but there's no real perf impact of this change. I can trim it down to just the stable if there's any interest in that.

muursh commented 2 months ago

I would note though that specialization is probably the least likely feature to be stabilized in the near future, so depending on your plans to remove that from plonky2_field, the introduction of these features may or may not lengthen the timeline to stability (assuming that's your goal).

I'd rather avoid adding more unstable features no matter what tbh.

Other than micro-benchmarks, but there's no real perf impact of this change. I can trim it down to just the stable if there's any interest in that.

I'm open to that.