Skip to content

Study on refactoring the series constructor #57952

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

aureliobarbosa
Copy link
Contributor

@aureliobarbosa aureliobarbosa commented Mar 21, 2024

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

This is an study on refactoring the series constructor, with emphasis on two points:

  • clear separation of the tasks;
  • and reduction of code duplication.

In particular, it should noticed that data manipulation on dictionaries and series data were duplicate and it was possible to eliminate the function self._init_dict() by reusing logic used to create series objects from other series.

Another interesting point is that, after refactoring, it became evident that the current code uses twice as much memory for manipulating dictionaries, as opposed to lists, with the same data set (tests were done locally with 10 million random numbers). In this case, it is possible to reduce the memory usage while creating the Series with dictionaries by up to 25% by avoiding the creation of a tuple from dictionary keys.

As mentioned above, this is an study and the main objective of this PR is to check if tests passes on all platforms.
Nevertheless, if any core member can take a look on it, I would be glad to receive a feedback.

If the community decide that any idea introduced here are useful for integration in the main branch, I would be glad to take them from this work and do separate PR with them.

P.S.: This branch diverged a little bit from main, but the only changes introduced so far were related to #57889. Those changes were incorporated on this PR.

Regards

EDIT: typo and P.S.

… to the less restrictive case. With comments.
@aureliobarbosa aureliobarbosa changed the title Study on Refactor series constructor Study on refactoring the series constructor Mar 21, 2024
@aureliobarbosa aureliobarbosa deleted the refactor_series_constructor branch April 11, 2024 17:18
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.

2 participants