Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #34253

Re: using smtp sent large file upto 60MB

References <1d8228ff-8f9e-4258-8927-2f964c36d8bf@n5g2000vbk.googlegroups.com> <mailman.454.1354615672.29569.python-list@python.org> <cc9e95d6-5221-4749-938e-791222e04427@y5g2000pbi.googlegroups.com> <50BE1990.4020009@shopzeus.com>
Date 2012-12-05 07:54 +1100
Subject Re: using smtp sent large file upto 60MB
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.475.1354654470.29569.python-list@python.org> (permalink)

Show all headers | View raw


On Wed, Dec 5, 2012 at 2:41 AM, Laszlo Nagy <gandalf@shopzeus.com> wrote:
> If you still don't want to accept this suggestion, then go ahead! Write a
> program, send out 100MB emails, and you will see for yourself that it just
> doesn't work.

But be aware of a few things.

1) Converting 1MB of binary data into a MIME-packaged email is going
to result in about 2MB of text. (It's about 1.5MB for base 64
encoding, which is one of the most common used, plus a bit more for
structure around it, and rounding up, call it two meg.)

2) If that 2MB of text is stored as a Python text string, it could
potentially consume 4MB or 8MB of memory, unless you're on Python 3.3,
in which case it will be only 2MB..

3) That 2-8MB has to be contiguous.

4) Any manipulation of the resulting string - which will quite
probably happen as it's built, as it gets connected to the email, etc,
etc, etc - will require even more copies of the string.

So all in all, you need a LOT of memory to do your encoding. That's
why you're seeing MemoryError - it is simply impossible to attach a
huge file to an email without using a fair amount of memory. (It's
possible to use that memory a bit at a time, but since emails are
generally small, most encoding libraries won't be written to do that.
This isn't like movie editing, where it's common to work with files
larger than your RAM.)

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

using smtp sent large file upto 60MB moonhkt <moonhkt@gmail.com> - 2012-12-04 00:15 -0800
  Re: using smtp sent large file upto 60MB Chris Angelico <rosuav@gmail.com> - 2012-12-04 21:07 +1100
    Re: using smtp sent large file upto 60MB moonhkt <moonhkt@gmail.com> - 2012-12-04 07:20 -0800
      Re: using smtp sent large file upto 60MB Laszlo Nagy <gandalf@shopzeus.com> - 2012-12-04 16:41 +0100
      Re: using smtp sent large file upto 60MB Chris Angelico <rosuav@gmail.com> - 2012-12-05 07:54 +1100
        Re: using smtp sent large file upto 60MB moonhkt <moonhkt@gmail.com> - 2012-12-04 16:54 -0800
          Re: using smtp sent large file upto 60MB Chris Angelico <rosuav@gmail.com> - 2012-12-05 16:34 +1100
            Re: using smtp sent large file upto 60MB moonhkt <moonhkt@gmail.com> - 2012-12-04 23:40 -0800
          Re: using smtp sent large file upto 60MB Michael Torrie <torriem@gmail.com> - 2012-12-05 08:01 -0700
            Re: using smtp sent large file upto 60MB moonhkt <moonhkt@gmail.com> - 2012-12-10 07:51 -0800

csiph-web