Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: Varnishtuner.py (github.com/unixy)
34 points by jjoe on April 18, 2015 | hide | past | favorite | 9 comments



Admittedly, I generally write procedural and/or functional python code... but how is:

  class CPUInfo(dict):
	def __init__(self, *args):
		dict.__init__(self, args)

	def __getitem__(self, key):
		val = dict.__getitem__(self, key)
		return val

	def __setitem__(self, key, val):
		dict.__setitem__(self, key, val)
Different from:

    class CPUInfo(dict):
        pass
Doesn't the overrides behave just like dict does?


Author probably has future plans for the class. I've seen people write classes like that to later do overloading. Others write out the methods to sort of document that those are the ones they are using. I know it might not be one's cup of tea, but let he who writes perfect code every time push to production without testing it first.


Well, it's nice to see my intuition was right. Seems a little redundant as documentation - at least for classes in the standard lib. And I'd prefer the diff from "pass" to "added overloaded method" rather than "changed standard method". I think.


I was going to ask the same thing.


One thing I'd suggest right off the bat is psutil. It looks like y'all did a lot of manual work to gather basic system information that you'd get out of the box with psutil. Plus, they've abstracted a lot of the cross-platform inconsistencies.


Believe me, I did consider it. It'd have made things easier a bit. But the goal (as stated in Github) is to not depend on any external module. Execution flow should be to wget && python varnishtuner.py similar to the way mysqltuner.pl works.


Just a suggestion. If you want a single file - why not package everything as an egg? Something that remotely resembles static linking in compiled languages.

I mean, as a part of build process[1] create a ZIP file, containinng all the dependencies and a file called `__main__.py`. Name that file `varnishturner.egg`, and just `python varnishturner.egg` would do the trick.

Or you can ignore this arcane approach suggestion and just publish on PyPI. I suppose Python installations without pip (or at least easy_install) are rare sights.

___

[1] Custom `Makefile`s to the rescue, or there's `bdist_egg` in distutils, although you'd have to write dependency packaging logic by yourself. For example, you can check how lxml does this with their `STATICDEPS=True python setup.py bdist_egg` process.


Do you have a link to the mysqltuner.pl?





Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: