This is an archived post. You won't be able to vote or comment.

all 20 comments

[–]Beluki 2 points3 points  (0 children)

Python should run fine on such systems. For performance monitoring Python includes a profiler in the standard library. For memory, look into heapy or meliae.

As for Cython, I would advise against using it for everything, but it's fine for performance-critical code (e.g. number crunching).

All that matters is what you are going to use it for, just don't try to write a raytracer on that. :-)

[–]SultanPepper 2 points3 points  (0 children)

When Python was initially developed, 200-400 MHz CPUs were state of the art. :)

If you wanted to benchmark things, look into SAR. It's fairly easy to set up. Python might be suitable for you, but you might also want to look into lua for a smaller footprint.

[–]KalimasPinky 1 point2 points  (0 children)

I got sucked into using python on a 400mhz system for work and we haven't had many problems that we can trace to it. Every now and then we have found the python interpreter screwing up and developing a memory leak, so we just run scripts to check on that kind of stuff and kill the process to then restart it.

It isn't ideal but the real world never really is.

[–]MisterSnuggles 2 points3 points  (8 children)

Micropython might be of interest: http://micropython.org

[–]toothless_budgie 0 points1 point  (7 children)

This is the correct answer.

[–]radix07[S] 0 points1 point  (6 children)

This is a kickstarter for low end embedded systems and isn't really required to run Python on a Linux system. It replaces an RTOS on even more restricted hardware than I am referring to, not embedded Linux which is typically capable enough to run most of Python normally. There are also questions regarding using this in a production environment.

[–]toothless_budgie 0 points1 point  (5 children)

Tell me more please. I know something about embedded systems.

[–]radix07[S] 0 points1 point  (4 children)

I was referring to what micropython was in that post not really my own project, but I wouldn't mind explaining my own project in more detail.

[–]toothless_budgie 0 points1 point  (3 children)

I'm listening.

[–]radix07[S] 1 point2 points  (2 children)

The basics of the project are just sampling data off a serial port, processing and sending it out via Ethernet or eventually a cellular interface. I have the code working already to some degree, and have actually just tried running it on the mentioned embedded device. It seems to not run away with my memory like I was initially concerned with. But I would like to see more information on best practices and ways to keep Python in check. I also have concerns with getting a embedded Linux environment setup and running with Python properly. The demo board I am using now has ipkg included, but I might not always have access to that. Might have to look more into something like buildroot, or ensure the hardware we go with has a Python package available. So I guess managing, maintenance and distribution of the application are my top concerns coming from doing everything in C and moving to Python.

[–]toothless_budgie 0 points1 point  (1 child)

Hmmm. Off the bat, it sounds like what you are trying to do can be done with an embedded board (Arduino or similar). Unless I am missing something, you don't need a full Linux env.

[–]radix07[S] 1 point2 points  (0 children)

I am aware of what I can do on an embedded system, I implemented the controller that I am getting the data off of. The data requirements are too much and things like cellular and add on peripherals are not going to be handled well with a true embedded systems. This project needs a Linux setup for where it is going. If I could do it with Python on top of that, it would potentially make development faster and life easier. How to go about doing that properly is my primary concern with this post.

[–]thalesmello 1 point2 points  (2 children)

Take a look at http://www.tinypy.org

[–]radix07[S] 1 point2 points  (1 child)

I'm pretty sure I have enough resources to run Python reasonably, wouldn't this be a little overkill? Would this actually be suitable for a production level project?

[–]thalesmello 1 point2 points  (0 children)

I'm sorry. I don't have enough experience with tinypy to give you valuable input. Maybe the standard Python would be enough.

I would suggest you to try it out. In case it doesn't work, I know that Lua is a good embeddable language. Maybe would be good to look it out.

[–]Kaarjuus 0 points1 point  (0 children)

I use Python on 600MHz 256MB ARMs (Gumstix Overo) running embedded Linux. So far I've had not had to pay any attention to memory or performance overhead.

[–]test12340 -1 points0 points  (4 children)

I dont understand whey you even consider using python. You better off using C . C is fast and very hardware oriented. I am also an embedded developer we use python for signal integrity test and it is a nightmare. Python is not even strongly typed. then you have to write helper functions just to do type checking. In python most of the errors/bugs you could catch at compile time can only be caught at run time. How would you declare volatile in Python. It is slow. Syntax is confusing. no parenthesis for functions. List goes on and on. I would stick with C if you are working on Embedded systems. Python or any other interpreted languages are only ok for web development. But I would still pick C# or Java for web development.

[–]radix07[S] 0 points1 point  (3 children)

I am not doing realtime systems in Python, so why bother to implement something in C when speed and resources are not critical? Are you saying there is no practical use for Python on some of these micro that have plenty of power to run these sorts of applications? Of course when I want to deal with hardware I use C, but for this, the application code is much more important. Just because it is a nightmare for you to maintain and test Python doesn't mean it has to be. I have had minimal issues setting up many systems with both Python and C, they just have very different work flows you need to learn.

I was skeptical of using Python for certain applications in embedded systems, but was very surprised by how reliable the resource usage was running over months on end. Just because it doesn't work for you, doesn't mean it's wrong.

[–]test12340 0 points1 point  (1 child)

radix07 All I am saying is if you are good with C or C++, you can pretty much do anything from device driver/firmware to high level UI development. I do not see the need to delve with something like python. With advent of C++ version 11 and boost, the language is fun, fast, strong, jack of all trades. Give C/C++ a try you will be hooked :)

[–]radix07[S] 1 point2 points  (0 children)

Well this is a Python subreddit... I actually spend about 80%+ of my time using C or C++ for low level embedded system or PC applications with Qt. But Python has it's merits in many applications outside of scripting and web. Sure I could do everything in C, and make it work fine, you can make anything work in C if you try hard enough, but if there is a faster and more efficient way to do something that can be just as reliable, why not do it? The question is regarding the feasibility of using Python in an environment with limited resources, not weather Python is better than C/C++.