myclabs / myclabs/DeepCopy

Make it faster

Open
#56 16 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
PHP
Stars
8.9k
Forks
110
PR merge metrics
No merged PRs in 30d

Description

Last time I looked, I couldn't find any way to really squeeze much more perf. This is mainly due to the fact that DeepCopy deep copy an object. As such, you cannot assume the properties of that object as values can be dynamically added. The result is DeepCopy must rely on a brand new instance of ReflectionObject each time, even if you get two objects of the same class.

A way to change that would maybe to add a mode to clone class instances instead, i.e. to rely on ReflectionClass and cache it somehow.

But to be honest this is just an idea like that. I'm actually not sure if it's really worth it, maybe it would be better to start by having a benchmark and see if the perf gain is worth it.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the DeepCopy implementation around its use of ReflectionObject and the object-cloning path described in the issue. Investigate whether ReflectionClass caching or a class-instance mode is viable, then add a benchmark to measure the performance gain before deciding what change is justified.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.