diff --git a/neet/boolean/logicnetwork.py b/neet/boolean/logicnetwork.py
index 69f44fc..9f1123b 100644
--- a/neet/boolean/logicnetwork.py
+++ b/neet/boolean/logicnetwork.py
@@ -2,6 +2,7 @@
 # Use of this source code is governed by a MIT
 # license that can be found in the LICENSE file.
 import re
+from neet.python3 import *
 from neet.statespace import StateSpace
 from neet.exceptions import FormatError
 
@@ -88,7 +89,7 @@ class LogicNetwork(object):
                 raise ValueError("Invalid table format")
             conditions = set()
             for condition in row[1]:
-                conditions.add(''.join([str(int(s)) for s in condition]))
+                conditions.add(''.join([str(long(s)) for s in condition]))
             self.table.append((row[0], conditions))
 
         if reduced:
@@ -105,15 +106,15 @@ class LogicNetwork(object):
         self._encoded_table = []
         for indices, conditions in self.table:
             # Encode the mask.
-            mask_code = 0
+            mask_code = long(0)
             for idx in indices:
                 mask_code += 2 ** idx  # Low order, low index.
             # Encode each condition of truth table.
             encoded_sub_table = set()
             for condition in conditions:
-                encoded_condition = 0
+                encoded_condition = long(0)
                 for idx, state in zip(indices, condition):
-                    encoded_condition += 2 ** idx if int(state) else 0
+                    encoded_condition += 2 ** idx if long(state) else 0
                 encoded_sub_table.add(encoded_condition)
             self._encoded_table.append((mask_code, encoded_sub_table))
 
@@ -134,7 +135,7 @@ class LogicNetwork(object):
         for state in sub_table[1]:
             # State excluding source.
             state_sans_source = state[:i] + state[i + 1:]
-            if int(state[i]) == 1:
+            if long(state[i]) == 1:
                 counter[state_sans_source] = counter.get(
                     state_sans_source, 0) + 1
             else:
diff --git a/neet/python3.py b/neet/python3.py
new file mode 100644
index 0000000..b3b118d
--- /dev/null
+++ b/neet/python3.py
@@ -0,0 +1,9 @@
+# Copyright 2018 ELIFE. All rights reserved.
+# Use of this source code is governed by a MIT
+# license that can be found in the LICENSE file.
+
+import sys
+if sys.version_info > (3,):
+    long = int
+    unicode = str
+
diff --git a/neet/statespace.py b/neet/statespace.py
index fc8230b..609c2c8 100644
--- a/neet/statespace.py
+++ b/neet/statespace.py
@@ -1,6 +1,7 @@
 # Copyright 2016-2017 ELIFE. All rights reserved.
 # Use of this source code is governed by a MIT
 # license that can be found in the LICENSE file.
+from .python3 import *
 import numpy as np
 
 class StateSpace(object):
@@ -201,7 +202,7 @@ class StateSpace(object):
         :returns: a unique integer encoding of the state
         :raises ValueError: if ``state`` has an incorrect length
         """
-        encoded, place = 0, 1
+        encoded, place = long(0), long(1)
 
         base = self.__base
         if self.is_uniform:
@@ -213,7 +214,7 @@ class StateSpace(object):
                 encoded += place * x
                 place *= b
 
-        return encoded
+        return long(encoded)
 
     def encode(self, state):
         """

logic network update function fails with large number of nodes
Above about 62 nodes, the update function for logic networks fails due to an issue with encoding states of the network.
diff --git a/test/test_asynchronous.py b/test/test_asynchronous.py
index 2dce250..5b6b7b1 100644
--- a/test/test_asynchronous.py
+++ b/test/test_asynchronous.py
@@ -2,6 +2,7 @@
 # Use of this source code is governed by a MIT
 # license that can be found in the LICENSE file.
 import unittest
+from neet.python3 import *
 from neet.asynchronous import transitions
 from neet.automata import ECA
 from neet.boolean.examples import s_pombe, s_cerevisiae, c_elegans
@@ -68,7 +69,7 @@ class TestAsync(unittest.TestCase):
         for net in [s_pombe, s_cerevisiae, c_elegans]:
             for states, _ in transitions(net, encoded=True):
                 for state in states:
-                    self.assertIsInstance(state, int)
+                    self.assertIsInstance(state, (int, long))
             for states, _ in transitions(net, encoded=False):
                 for state in states:
                     self.assertIsInstance(state, list)
@@ -77,7 +78,7 @@ class TestAsync(unittest.TestCase):
             for size in [5, 8, 10]:
                 for states, _ in transitions(net, size, encoded=True):
                     for state in states:
-                        self.assertIsInstance(state, int)
+                        self.assertIsInstance(state, (int, long))
                 for states, _ in transitions(net, size, encoded=False):
                     for state in states:
                         self.assertIsInstance(state, list)
diff --git a/test/test_statespace.py b/test/test_statespace.py
index 813597d..80b77f3 100644
--- a/test/test_statespace.py
+++ b/test/test_statespace.py
@@ -2,10 +2,10 @@
 # Use of this source code is governed by a MIT
 # license that can be found in the LICENSE file.
 import unittest
+from neet.python3 import *
 from neet.statespace import StateSpace
 import numpy as np
 
-
 class TestStateSpace(unittest.TestCase):
     def test_invalid_spec_type(self):
         with self.assertRaises(TypeError):
@@ -277,3 +277,17 @@ class TestStateSpace(unittest.TestCase):
         self.assertFalse([0, 2, 1] not in StateSpace([2, 3, 2]))
         self.assertTrue([0, 1] not in StateSpace([2, 2, 3]))
         self.assertTrue([1, 1, 6] not in StateSpace([2, 3, 4]))
+
+    def test_long_encoding(self):
+        state_space = StateSpace(10)
+        code = state_space.encode(np.ones(10, dtype=int))
+        print(type(code))
+        self.assertIsInstance(code, long)
+
+        state_space = StateSpace(68)
+        code = state_space.encode(np.ones(68, dtype=int))
+        self.assertIsInstance(code, long)
+
+        state_space = StateSpace(100)
+        code = state_space.encode(np.ones(100, dtype=int))
+        self.assertIsInstance(code, long)

pip install -e .
parse_log_pytest
requirements.txt
nose pytest
apt-get update apt-get install -y gcc
3.5
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs==22.2.0
certifi==2021.5.30
decorator==4.4.2
importlib-metadata==4.8.3
iniconfig==1.1.1
-e git+https://github.com/ELIFE-ASU/Neet.git@fbc1f937c407974c04c847d44517fea5ea76176f#egg=neet
networkx==2.5.1
nose==1.3.7
numpy==1.19.5
packaging==21.3
pluggy==1.0.0
py==1.11.0
pyinform==0.2.0
pyparsing==3.1.4
pytest==7.0.1
tomli==1.2.3
typing_extensions==4.1.1
zipp==3.6.0

name: Neet
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - attrs==22.2.0
      - decorator==4.4.2
      - importlib-metadata==4.8.3
      - iniconfig==1.1.1
      - networkx==2.5.1
      - nose==1.3.7
      - numpy==1.19.5
      - packaging==21.3
      - pluggy==1.0.0
      - py==1.11.0
      - pyinform==0.2.0
      - pyparsing==3.1.4
      - pytest==7.0.1
      - tomli==1.2.3
      - typing-extensions==4.1.1
      - zipp==3.6.0
prefix: /opt/conda/envs/Neet

test/test_asynchronous.py::TestAsync::test_canary test/test_asynchronous.py::TestAsync::test_transitions_encoded test/test_asynchronous.py::TestAsync::test_transitions_not_network test/test_asynchronous.py::TestAsync::test_transitions_require_update test/test_asynchronous.py::TestAsync::test_transitions_sum_to_one test/test_statespace.py::TestStateSpace::test_base_mismatch test/test_statespace.py::TestStateSpace::test_check_states_uniform test/test_statespace.py::TestStateSpace::test_check_states_varied test/test_statespace.py::TestStateSpace::test_decode_encode_nonuniform test/test_statespace.py::TestStateSpace::test_decode_encode_uniform test/test_statespace.py::TestStateSpace::test_decoding_nonuniform test/test_statespace.py::TestStateSpace::test_decoding_uniform test/test_statespace.py::TestStateSpace::test_encode_decode_nonuniform test/test_statespace.py::TestStateSpace::test_encode_decode_uniform test/test_statespace.py::TestStateSpace::test_encoding_error test/test_statespace.py::TestStateSpace::test_encoding_nonuniform test/test_statespace.py::TestStateSpace::test_encoding_uniform test/test_statespace.py::TestStateSpace::test_invalid_base_type test/test_statespace.py::TestStateSpace::test_invalid_base_value test/test_statespace.py::TestStateSpace::test_invalid_spec_type test/test_statespace.py::TestStateSpace::test_invalid_spec_value test/test_statespace.py::TestStateSpace::test_long_encoding test/test_statespace.py::TestStateSpace::test_nonuniform_bases test/test_statespace.py::TestStateSpace::test_states_boolean test/test_statespace.py::TestStateSpace::test_states_boolean_list test/test_statespace.py::TestStateSpace::test_states_count test/test_statespace.py::TestStateSpace::test_states_nonboolean test/test_statespace.py::TestStateSpace::test_states_nonboolean_list test/test_statespace.py::TestStateSpace::test_uniform_bases
neet/statespace.py neet/python3.py neet/boolean/logicnetwork.py
neet/statespace.py neet/python3.py neet/boolean/logicnetwork.py