Skip to content

Conversation

@ss2165
Copy link
Member

@ss2165 ss2165 commented Apr 30, 2025

NOT INTENDED FOR MERGING, JUST FOR DISCUSSION.

There are a bunch of common/pythonic things one would want to do on core types that we don't provide pre-existing functionality for. I think we should provide it in some way.

The limitations are primarily that without some kind of trait/type class system it is hard to provide this stuff generically (e.g. functions that work for all iterators over some type). Given this is something Guppy may add in future, I am reluctant to include things in the standard library.

I propose instead providing this from a separate package that isn't tied to language stability or maintenance. This package:

  • Can add and remove functionality more easily
  • Should not do any custom compilation, should be valid standalone guppy functions and types
  • Can be relaxed on code duplication across types

In this RFC PR I have collected some such functions I had lying around. It includes:

  • enumerate and zip for arrays over any type
  • utility functions over arrays of booleans

I have taken the approach of making these functions look like common python equivalents. But the resemblance is superficial since they only work on types. An alternative approach is to make them methods on the array type, rust style, which might make it more palatable for the standard library but with the obvious downside that people won't naturally find them and use them.

Some missing things I'd like to add:

  • equivalent things for arrays of ints and floats
  • min/max
  • sum
  • in place sorting of an array
  • round (?)

@hugrbot
Copy link
Collaborator

hugrbot commented Apr 30, 2025

Hey there and thank you for opening this pull request! 👋

We require pull request titles to follow the Conventional Commits specification
and it looks like your proposed title needs to be adjusted.

Your title should look like this. The scope field is optional.

<type>(<scope>): <description>

If the PR includes a breaking change, mark it with an exclamation mark:

<type>!: <description>

and include a "BREAKING CHANGE:" footer in the body of the pull request.

Details:

Unknown release type "RFC" found in pull request title "RFC: separate utils library on core types". 

Available types:
 - feat
 - fix
 - docs
 - style
 - refactor
 - perf
 - test
 - ci
 - chore
 - revert

@ss2165
Copy link
Member Author

ss2165 commented Apr 30, 2025

If we go with separate package should that have it's own repo or can it live here?
It would be very useful for testing and CI to live here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants