Python Forum
Are there optimizer for static code?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Are there optimizer for static code?
#5
For example classes have dicts for their methods and attributes.
If I remind right, a dict has a size of 112 bytes (since Python 3.6).
If you have only 10-1000 objects, you just don't care.
But with one million objects, you care about memory consumption.
In this case, use __slots__ for this kind of classes.

If you have a for-loop, try to solve this not in Python.
Looping is not very efficient in Python. You can do this in cython.

Maybe you can post some example code with example data.


EDIT: Very often constructs like a list comprehension are faster than using generators. Generators are used, if you have much data to process and want to solve this in a iterative way and saving memory consumption. Maybe you can also implement a generator in Cython, which should run faster and saves memory.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Messages In This Thread
RE: Are there optimizer for static code? - by DeaD_EyE - Nov-02-2019, 08:57 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  problem usage of static method akbarza 5 739 Feb-03-2024, 07:43 AM
Last Post: paul18fr
  Static type checking with PyPy pitosalas 1 575 Dec-14-2023, 09:29 PM
Last Post: deanhystad
  Class member become static Quasar999 1 799 Sep-16-2023, 12:52 PM
Last Post: deanhystad
Photo Output Static image on HDMI2 random816382 0 1,500 Oct-18-2021, 11:21 AM
Last Post: random816382
Question Google Foobar- Code works in my IDE but not in foobar. Static method? pr3ttykitty 4 5,161 Feb-24-2021, 05:03 PM
Last Post: nilamo
  Using static methods for library? giu88 4 3,084 Sep-12-2018, 07:52 AM
Last Post: giu88
  Notebook is rendered as static html by github miner_tom 2 3,234 Aug-23-2018, 09:00 PM
Last Post: perfringo
  need to alter static picture to video file mika 1 2,878 Feb-23-2018, 02:11 PM
Last Post: ka06059
  Updating & Accessing a "Static" List Bass 4 4,604 May-23-2017, 07:12 PM
Last Post: Bass

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020