9 ms·
I usually don't comment on these posts, but I felt the need to in this one. A couple of things stood out: - Python 2.4? Really? In 2014? - Yes, writing compat
by orf 11y ago
I usually don't comment on these posts, but I felt the need to in this one. A couple of things stood out:
- Python 2.4? Really? In 2014?
- Yes, writing compatible code with a 10+ year old release of Python is going to be hard. Who uses 2.4 still? You have to use the lowest common denominator, I mean I don't think Python 2.4 even supports context managers!
- Yes, in 2014 you should be supporting Python 3, or at least have it on your roadmap.
- The ethernet address (MAC?) via uuid.get_node(). Or for something a bit more advanced you can use netifaces[1] (or even better psutil.net_if_addrs[3]). One of Pythons core strengths is the number and variety of the packages available. Took 2 seconds of googling to find a cross platform solution.
- Calling C from Python is really really simple. Use the built in ctypes library, or something better like cffi[2]
I'm obviously firmly in the Python camp so perhaps I'm a bit biased, but I don't see any clearcut reason to switch other than "the current code is not optimal, let's re-write it in X", where X could be anything. I would actually say Go would be a much better fit than Lua in this situation. I guess the memory reduction/CPU usage is a point, but really your program seems to be network orientated. What's wrong with asyncio? How is replacing everything with a C library actually better?
1. https://pypi.python.org/pypi/netifaces https://pypi.python.org/pypi/netifaces
2. https://cffi.readthedocs.org/en/latest/overview.html#simple-example-abi-level-in-line https://cffi.readthedocs.org/en/latest/overview.html#simple-...
3. https://pythonhosted.org/psutil/#psutil.net_if_addrs https://pythonhosted.org/psutil/#psutil.net_if_addrs
- ovis 11y agoThe article did mention a desire to use netifaces, but I didn't quite understand why the author thought they couldn't.
- brimworks 11y agouuid.get_node(): ...and which iface's address will I get if I'm on a multi-interface machine (not to mention that it was added in 2.5 version of Python)? netifaces: ...would require me to build a C extension which would mean going down the rabbit hole of building and bundling python and this library.
- viraptor 11y agoAs opposed to shipping LUA with C extensions? Also, there are things like shedskin: https://github.com/shedskin/shedskin https://github.com/shedskin/shedskin - you don't even have to ship python. Or micropython: https://github.com/micropython/micropython https://github.com/micropython/micropython with the code embedded. Then you can easily either shell out or include any C extensions you want.
- vetinari 11y agoI just tried it (it was uuid.getnode(), without underscore) and I got the interface with default gateway set.
- kt9 11y agoHi, I'm the Founder at Distelli and I wrote the original version of the Distelli agent in Python that Brian rebuilt using Lua. The main reason I picked Python 2.4 is because we have large enterprise customers that are / were running Python 2.4 on servers and I had to support Python 2.4 to serve their use case.
- bb88 11y agoIn that case, Lua makes a lot of sense, frankly. I can write 100 lines of code in perl, but trying to get that deployed on mac, windows and linux can be a nightmare, especially if its using a library external to perl. (EDIT: LUA->Lua)
- glibgil 11y agoLUA? Still?
- deleted 11y ago[deleted]
- deleted 11y ago[deleted]
- talloaktrees 11y agoI think he referring to LUA vs Lua
- etiene 11y agoLua used to be LUA, you'll find LUA written in old source code comments :) Don't be so mad about the Lua Uppercase Accident :)
- batbomb 11y agoThey were probably running RHEL5, but even in 2014 they would have been in the Production 3 phase which is really should only be used for legacy purposes, and that's definitely not the sort of system you push new software to. Red Hat even pushes those customers towards virtualization because a) hardware rarely lasts 7 years and b) they won't bother backporting drivers for new hardware to the old kernel at that point. I still use a few RHEL5 machines but nobody would ever dream of pushing new software to them.
- detaro 11y agoI'd guess RHEL 5 is to blame for supporting 2.4 until 2014.
- tetha 11y agoTo extend this, CentOS 7 has no simple python3 package available (I'm aware of scl). This will be a massive hassle on the way forward.
- loganekz 11y agosudo yum -y install epel-release && sudo yum -y install python34 python35 will be soon be coming to EPEL also.
- icebraining 11y agoInstalling from source is really not that terrible - we do so for one of our clients (running CentOS 6.5, IIRC) and it just took us a couple of hours to have a full build script.
- sciurus 11y agoWhat's wrong with SCL?
- ubernostrum 11y agoHonestly, every time I hear a story like the one in the OP, I'm tempted to find a way to make once-per-decade upgrades be so ruinously expensive that companies will stop opting for agreements structured around them.
- cowsandmilk 11y agoI have customers that use RHEL 5 still (supported until 2017 or 2020 in the extreme), which ships with python 2.4 as the system python[1]. My solution was to use pyinstaller[2] to basically ship my own python, first 2.7, and now 3.5. [0] https://access.redhat.com/support/policy/updates/errata/#Life_Cycle_Dates https://access.redhat.com/support/policy/updates/errata/#Lif... [1] http://distrowatch.com/table.php?distribution=redhat http://distrowatch.com/table.php?distribution=redhat [2] http://www.pyinstaller.org http://www.pyinstaller.org
- mrits 11y agoI don't do a lot of python anymore but we never depended on installed version. Everything was in an a virtual environment where we could control the libraries.
- pyre 11y agovirtualenv doesn't manage different versions of the Python interpreter though. By default it uses the system Python. If you want another Python, then you need to install it yourself (somehow) and then point virtualenv at it. virtualenv is just a way to create separate bundles of libraries.
- BuckRogers 11y agoIt's for both libraries and different versions of Python. This is common and trivial. I install specific versions of Python using the Deadsnakes PPA since I can easily pull in any version going back to 2.3 if I need. Or you can compile and install from source. Then create a folder for your project, 'virtualenv -p /usr/bin/python3.5 venv' to create the venv in that directory. Activate/deactivate the environment as you wish when you want go between the system Python environment and the one in your folder.
- pyre 11y agoI replied to @mrits because @mrits was presenting virtualenv as replacement for using pyinstaller to manage the installation of non-OS-managed Python versions (which @cowsandmilk was talking about). I'm unsure how what I said: > If you want another Python, then you need to install it yourself (somehow) and then point virtualenv at it. Differs from what you are saying: > 'virtualenv -p /usr/bin/python3.5 venv'
- technomancy 11y ago> "the current code is not optimal, let's re-write it in X" I read it more as "relying on a runtime that must be installed on the user's OS instead of included in our executable is a nightmare". The dramatically reduced conceptual footprint of the language is a nice bonus though.
- michaelcampbell 11y agoWas it by design your first 3 points (of 5) are the same?
- Chris2048 11y ago> Yes, in 2014 you should be supporting Python 3, or at least have it on your roadmap. Why? What's wrong with 2.7?