in fixed_objects.py:
try: import png except ImportError: png = None #Trying to import PIL try: from PIL import Image except ImportError: Image = None #line 627 def save_png(self, path): if not path.endswith(".png"): path += ".png" #If pypng installed if png: f = open(path, "wb") width, height, rgba_array = self.to_array() writer = png.Writer(width, height, alpha=True) writer.write_array(f, rgba_array) f.flush() f.close() #if PIL installed elif Image: width, height, rgba_array = self.to_array() im = Image.fromstring("RGBA", (width, height), rgba_array.tostring()) im.save(path) else: raise ValueError, "Missing dependency: pypng or PIL needed for " \ "PNG support"
not sure if faster cause i don't have pypng, but much more people have PIL than pypng, and its easier to install
also, why not replace the pythonic arrays with numpy?
should be faster
Last edited by roijac (2012-08-27 08:30:52)
Offline
roijac wrote:
not sure if faster cause i don't have pypng, but much more people have PIL than pypng, and its easier to install
also, why not replace the pythonic arrays with numpy?
should be faster
Thanks -- I managed to download a copy of PIL, so I'll try it out. I've never used Numpy, but that might be worth a try, too
(The mobile internet where we're staying is sooo slow. I can load one page about every five minutes... We're at the supermarket, so I downloaded the documentation for Numpy & PIL as PDFs )
Last edited by blob8108 (2012-08-27 13:12:27)
Offline
blob8108 wrote:
roijac wrote:
not sure if faster cause i don't have pypng, but much more people have PIL than pypng, and its easier to install
also, why not replace the pythonic arrays with numpy?
should be fasterThanks -- I managed to download a copy of PIL, so I'll try it out. I've never used Numpy, but that might be worth a try, too
(The mobile internet where we're staying is sooo slow. I can load one page about every five minutes... We're at the supermarket, so I downloaded the documentation for Numpy & PIL as PDFs )
xD
Offline
blob8108 wrote:
roijac wrote:
not sure if faster cause i don't have pypng, but much more people have PIL than pypng, and its easier to install
also, why not replace the pythonic arrays with numpy?
should be faster(The mobile internet where we're staying is sooo slow. I can load one page about every five minutes... We're at the supermarket, so I downloaded the documentation for Numpy & PIL as PDFs )
I just love being in those positions. I like to pickup documentation when we stop for gas or something. Almost done... "DOWNLOAD FASTEEEEE...R."
Offline
MathWizz wrote:
blob8108 wrote:
(The mobile internet where we're staying is sooo slow. I can load one page about every five minutes... We're at the supermarket, so I downloaded the documentation for Numpy & PIL as PDFs )
I just love being in those positions. I like to pickup documentation when we stop for gas or something. Almost done... "DOWNLOAD FASTEEEEE...R."
Hehe
Presumably you live in one of those countries that has wifi hotspots *everywhere*? /jealous
Offline
blob8108 wrote:
MathWizz wrote:
blob8108 wrote:
(The mobile internet where we're staying is sooo slow. I can load one page about every five minutes... We're at the supermarket, so I downloaded the documentation for Numpy & PIL as PDFs )
I just love being in those positions. I like to pickup documentation when we stop for gas or something. Almost done... "DOWNLOAD FASTEEEEE...R."
Hehe
Presumably you live in one of those countries that has wifi hotspots *everywhere*? /jealous
Just about. xD
Offline
Hardmath123 wrote:
Err... an embarrassingly nonsecure socket-based chat.
Oh, like a telnet chat thing? Cool! Your next challenge is to make a MUD/multiplayer text-based game...
Have you done the competition-thing yet?
Oh, and cool: you're a curator!
Offline
blob8108 wrote:
Hardmath123 wrote:
Err... an embarrassingly nonsecure socket-based chat.
Oh, like a telnet chat thing? Cool! Your next challenge is to make a MUD/multiplayer text-based game...
... I'll try.
Have you done the competition-thing yet?
What, the one I was ranting about or the AI one that died a month ago? If it's the prior, I'm just about to post the outcome at the MaC forums.
Oh, and cool: you're a curator!
Thanks!
Offline
Hardmath123 wrote:
blob8108 wrote:
Have you done the competition-thing yet?
What, the one I was ranting about or the AI one that died a month ago? If it's the prior, I'm just about to post the outcome at the MaC forums.
The prior, of course (I still think we should have that competition, even if it's just you and me...)
EDIT: I finally made the wi-fi here work! Not that it's much quicker...
Last edited by blob8108 (2012-08-28 13:29:12)
Offline
MathWizz wrote:
@blob8108, you should add this line to you scratchblocks test:
Code:
code.onchange = refresh;
Oh, cool! Someone noticed that
Why should I add that? I don't understand... How would that help?
Offline
A quick update: I just made a single optimization to Kurt which made saving 150x faster: from about 12 minutes (literally!) to 5 seconds. *
This is just the saving step, project.save(). Things like compiling the project, parsing scratchblocks and loading images add several more seconds -- it mainly depends on how many images you have.
And I still have images yet to optimize!
In case you're interested: Scratch stores everything in an Object Table, which is basically a list of all the objects. When objects are found as properties of other objects, they get encoded as references to an index in the list. The change I made was to temporarily store the index on the object itself, rather than search through the list, comparing it with each object (which is really slow, as you can imagine...)
* these tests were run with my roads project, which has a single script that's 600 lines long...
Offline
blob8108 wrote:
MathWizz wrote:
@blob8108, you should add this line to you scratchblocks test:
Code:
code.onchange = refresh;
Oh, cool! Someone noticed that
Why should I add that? I don't understand... How would that help?
Live updating blocks.
@update awesome!
Offline
blob8108 wrote:
A quick update: I just made a single optimization to Kurt which made saving
And I still have images yet to optimize!
i tested pypng vs PIL, pypng is ~1 second faster on saving 1000 images, and i still believe numpy would be much faster
Offline
MathWizz wrote:
blob8108 wrote:
MathWizz wrote:
@blob8108, you should add this line to you scratchblocks test:
Code:
code.onchange = refresh;
Oh, cool! Someone noticed that
Why should I add that? I don't understand... How would that help?Live updating blocks.
It should already do that... ._.
EDIT: (checks) Yeah, it does for me. What are you using...?
Last edited by blob8108 (2012-08-28 14:52:33)
Offline
roijac wrote:
i tested pypng vs PIL, pypng is ~1 second faster on saving 1000 images, and i still believe numpy would be much faster
Thanks for testing that! I'm very surprised that PyPNG is faster -- I thought it was pure-Python, so I was expecting it to be much slower.
Have you also tested reading images? That's almost more important...
And yes, I'm definitely going to see if I can make image-y things faster using Numpy
Offline
blob8108 wrote:
roijac wrote:
i tested pypng vs PIL, pypng is ~1 second faster on saving 1000 images, and i still believe numpy would be much faster
Thanks for testing that! I'm very surprised that PyPNG is faster -- I thought it was pure-Python, so I was expecting it to be much slower.
Have you also tested reading images? That's almost more important...
And yes, I'm definitely going to see if I can make image-y things faster using Numpy
where are those scripts?
couldn't find the import part
Offline
roijac wrote:
blob8108 wrote:
roijac wrote:
i tested pypng vs PIL, pypng is ~1 second faster on saving 1000 images, and i still believe numpy would be much faster
Thanks for testing that! I'm very surprised that PyPNG is faster -- I thought it was pure-Python, so I was expecting it to be much slower.
Have you also tested reading images? That's almost more important...
And yes, I'm definitely going to see if I can make image-y things faster using Numpywhere are those scripts?
couldn't find the import part
Form.load_png -- see fixed_objects.py, line 673.
EDIT: line numbers are different in the latest version on Github (on the scratchblocks branch) to my version, of course...
Last edited by blob8108 (2012-08-28 15:16:40)
Offline
blob8108 wrote:
roijac wrote:
blob8108 wrote:
Thanks for testing that! I'm very surprised that PyPNG is faster -- I thought it was pure-Python, so I was expecting it to be much slower.
Have you also tested reading images? That's almost more important...
And yes, I'm definitely going to see if I can make image-y things faster using Numpywhere are those scripts?
couldn't find the import partForm.load_png -- see fixed_objects.py, line 673.
EDIT: line numbers are different in the latest version on Github (on the scratchblocks branch) to my version, of course...
oh i see
but the code is way to complicated for my understanding of pngs
btw, you should check your code with pylint from time to time...
Last edited by roijac (2012-08-28 15:43:51)
Offline
blob8108 wrote:
Hardmath123 wrote:
blob8108 wrote:
Have you done the competition-thing yet?
What, the one I was ranting about or the AI one that died a month ago? If it's the prior, I'm just about to post the outcome at the MaC forums.
The prior, of course (I still think we should have that competition, even if it's just you and me...)
Agreed. Too many cooks cook too much.
Offline
Hardmath123 wrote:
blob8108 wrote:
Hardmath123 wrote:
What, the one I was ranting about or the AI one that died a month ago? If it's the prior, I'm just about to post the outcome at the MaC forums.The prior, of course (I still think we should have that competition, even if it's just you and me...)
Agreed. Too many cooks cook too much.
But I'm HUNGRY. D:
Offline
roijac wrote:
btw, you should check your code with pylint from time to time...
Why is that...? What's funny?
MathWizz wrote:
Hardmath123 wrote:
blob8108 wrote:
(I still think we should have that competition, even if it's just you and me...)
Agreed. Too many cooks cook too much.
But I'm HUNGRY. D:
xD
Did you see this...?
blob8108 wrote:
MathWizz wrote:
Live updating blocks.
It should already do that... ._.
EDIT: (checks) Yeah, it does for me. What are you using...?
Offline
blob8108 wrote:
roijac wrote:
btw, you should check your code with pylint from time to time...
Why is that...? What's funny?
Offline
I think I've worked through most of the bugs, and it seems pretty solid! Can't wait to release it tomorrow...
Offline