Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Register
  • Sign in
  • Tryton Tryton
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 775
    • Issues 775
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 92
    • Merge requests 92
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • TrytonTryton
  • TrytonTryton
  • Issues
  • #3516
Closed
Open
Issue created Nov 21, 2013 by Cédric Krier@ced⚛Owner

Fix anti-pattern about create/write in loop

There are in some place this anti-pattern:

for record in records:
# do some stuffs
record.save()
# or
cls.create()
# or
cls.write()

This pattern is not very good for the cache management of Tryton as for each
create/write the cache of all the record in the records list will be reset.
So it doesn't take advantage at all of the smart cache.

Indeed this pattern should be used:

for sub_records in grouped_slice(records):
for record in sub_records:
# do some stuffs
# store change
cls.create(to_create)
cls.write(to_write)

grouped_slice will be a helper to make the "in_max" loop.

Files

Download Creator Timestamp Type
tryton-antipatern.txt @pokoli 2013-11-23 13:39:09.084000 UTC text/plain
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking